Mysql存储过程输出参数

时间:2017-01-26 12:05:51

标签: mysql stored-procedures output

输出参数有问题,当我运行我的代码时,它会输入数据库中的记录,但它不提供输出。请纠正此代码。

CREATE DEFINER=`spimran`@`%` PROCEDURE `addUserData1`(IN userDate datetime)

BEGIN
DECLARE siteUserID int;   

    DECLARE userCountry varchar(50);

    DECLARE userAccountId varchar(50);

    DECLARE SecurityId varchar(50);

    DECLARE Allocation varchar(50);

    DECLARE SecuritySymbol varchar(50);

    DECLARE ModelName varchar(50);

    DECLARE iteUploadInputId varchar(50);

    DECLARE TradeType varchar(50);

    DECLARE SecurityType varchar(50);

    DECLARE FromBranch varchar(50);

    DECLARE FromAccount varchar(50);

    DECLARE FromAccountType varchar(50);

    DECLARE FromInterest varchar(50);

    DECLARE FromCharge varchar(50);

    DECLARE ToBranch varchar(50);

    DECLARE ToAccount varchar(50);

    DECLARE ToAccountType varchar(50);

    DECLARE ToInterest varchar(50);

    DECLARE ToCommission varchar(50);

    DECLARE ToFees varchar(50);

    DECLARE ToTaxes varchar(50);

    DECLARE Currency varchar(50);

    DECLARE EuroSettle varchar(50);

    DECLARE Blotter varchar(50);

    DECLARE TrailerCodes varchar(50);

    DECLARE NarrativeTexts varchar(50);

    DECLARE InstrumentType varchar(50);

    DECLARE FACTORS varchar(50);

    DECLARE SEC_SET_CURRENCY varchar(50);

    DECLARE EXC_RATE varchar(50);

    DECLARE M_D_IND varchar(50);

    DECLARE CROSS_CURRENCY varchar(50);

    DECLARE SETTLE_POINTERS varchar(50);

    DECLARE GROSS_CREDIT varchar(50);

    DECLARE dateAdded datetime;

    DECLARE counter int;

    DECLARE UpdatedDate varchar(50);

    DECLARE NetDeposits varchar(50); 

    DECLARE MarketValue varchar(50);   

    DECLARE getTempData CURSOR FOR

    SELECT SU.siteUserID,SU.userCountry,SU.userAccountId,AWO.UpdatedDate,AWO.NetDeposits,WMS.SecurityId,WMS.Allocation,WSM.SecuritySymbol,WML.ModelName,IUI.iteUploadInputId,IUI.TradeType,IUI.SecurityType,IUI.FromBranch,IUI.FromAccount,IUI.FromAccountType,IUI.FromInterest,IUI.FromCharge,IUI.ToBranch,IUI.ToAccount,IUI.ToAccountType,IUI.ToInterest,IUI.ToCommission,IUI.ToFees,IUI.ToTaxes,IUI.Currency,IUI.EuroSettle,IUI.Blotter,IUI.TrailerCodes,IUI.NarrativeTexts,IUI.InstrumentType,IUI.FACTORS,IUI.SEC_SET_CURRENCY,IUI.EXC_RATE,IUI.M_D_IND,IUI.CROSS_CURRENCY,IUI.SETTLE_POINTERS,IUI.GROSS_CREDIT,IUI.dateAdded
    FROM tbl_site_user AS SU
    LEFT JOIN wahed_model_securities AS WMS ON SU.modelsFkId=WMS.ModelId
    LEFT JOIN wahed_security_master AS WSM ON WMS.SecurityId =WSM.id
    LEFT JOIN wahed_models_list AS WML ON WMS.ModelId =WML.id
    LEFT JOIN apex_wahed_overview AS AWO ON SU.userAccountId =AWO.AccountNumber             
    JOIN tbl_ite_uploads_input AS IUI
    WHERE  WMS.SecurityId!=6 AND SU.userAccountId!='' AND AWO.UpdatedDate=userDate
    ORDER BY userAccountId,WMS.SecurityId ASC;

       OPEN getTempData;    

        start_loop: loop
            fetch getTempData into siteUserID,userCountry,userAccountId,UpdatedDate,NetDeposits,SecurityId,Allocation,SecuritySymbol,ModelName,iteUploadInputId,TradeType,SecurityType,FromBranch,FromAccount,FromAccountType,FromInterest,FromCharge,ToBranch,ToAccount,ToAccountType,ToInterest,ToCommission,ToFees,ToTaxes,Currency,EuroSettle,Blotter,TrailerCodes,NarrativeTexts,InstrumentType,FACTORS,SEC_SET_CURRENCY,EXC_RATE,M_D_IND,CROSS_CURRENCY,SETTLE_POINTERS,GROSS_CREDIT,dateAdded;

                INSERT INTO tbl_ite_uploads (External_ID,TradeType,SecurityType,Security,CountryCode,Action,Price,Quantity,TradeDate,ValueDate,FromBranch,FromAccount,FromAccountType,FromInterest,FromCharge,ToBranch,ToAccount,ToAccountType,ToInterest,ToCommission,ToFees,ToTaxes,Currency,EuroSettle,Blotter,TrailerCodes,NarrativeTexts,InstrumentType,FACTORS,SEC_SET_CURRENCY,EXC_RATE,M_D_IND,CROSS_CURRENCY,SETTLE_POINTERS,GROSS_CREDIT,dateAdded)

                VALUES (userAccountId,SecuritySymbol,SecurityType,userAccountId,userCountry,'','50','',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP(),FromBranch,FromAccount,FromAccountType,FromInterest,FromCharge,ToBranch,ToAccount,ToAccountType,ToInterest,ToCommission,ToFees,ToTaxes,Currency,EuroSettle,Blotter,TrailerCodes,NarrativeTexts,InstrumentType,FACTORS,SEC_SET_CURRENCY,EXC_RATE,M_D_IND,CROSS_CURRENCY,SETTLE_POINTERS,GROSS_CREDIT,CURRENT_TIMESTAMP());

        end loop;   

        close getTempData;  
    SELECT * FROM tbl_ite_uploads;

END

0 个答案:

没有答案