I would like to create cursor inside the stored procedure which needs to fetch each record and do some calculation, this calculation depends on the other field int table. So based on the condition i need to return the value.
But when i try to do the calculation it gives
Line 21: Incorrect syntax near '@p1'.
Please help me as this is very high priority work for me.
Here is the stored procedure how it goes
Create Procedure DummyReport
DECLARE @TransCode varchar(20)
DECLARE @Flt_Amount int
DECLARE @p1 int
DECLARE Cur_Flt_Amt Cursor FAST_FORWARD FOR
SELECT Tbl_Transaction.int_TransCode,Tbl_Transaction.Flt_Amount FROM Tbl_Transaction WHERE txt_StateCode=@txt_StateCode and txt_DistrictCode=@txt_DistrictCode AND dat_Date <= CONVERT(DATETIME, @txt_Date2 , 102) AND (txt_AccountNO = @txt_AccountNo ) and (int_DPCode=@txt_DPCode)
FETCH NEXT FROM Cur_Flt_Amt INTO @TransCode, @Flt_Amount
WHILE @@FETCH_STATUS = 0
@p1 = dbo.AddFltAmount(@p1,@Flt_Amount) --here where i am getting error
create function AddFltAmount
Return @p1+ @fltAmt
Thanks in advance