Hi All,
I have created 2 cursors in a 2 stored procedures. I want to search records of 2nd cursor with each record of 1st cursor. Somehow I am stuck with structuring the procedure. Can someone help me with it?
My current procedure looks as follows:
DECLARE @CrsrBankVar CURSOR
DECLARE @CrsrCashVar CURSOR
/* Execute the procedure created earlier to fill the variable. */
EXEC OpenBKCrsr @BKNoMatch = @CrsrBankVar OUTPUT
EXEC OpenCBCrsr @CBNoMatch = @CrsrCashVar OUTPUT
/* Declaring variables to store data from cursor @CrsrBankVar */
DECLARE @BkDate as decimal(9,0),
@BkAmt as decimal(9,3)
/* Use the variable to fetch the rows from the cursor. */
FETCH NEXT FROM @CrsrBankVar INTO @BkDate, @BkAmt
WHILE (@@FETCH_STATUS = 0)
BEGIN
**************************
Here I want to compare each row from @CrsrCashVar with the
variables defined above
**** Need help to do so ***********
**************************
print @BkDate
print @BkAmt
PRINT '****************'
FETCH NEXT FROM @CrsrBankVar
END
CLOSE @CrsrBankVar
CLOSE @CrsrCashVar
DEALLOCATE @CrsrBankVar
DEALLOCATE @CrsrCashVar
GO
I have created 2 cursors in a 2 stored procedures. I want to search records of 2nd cursor with each record of 1st cursor. Somehow I am stuck with structuring the procedure. Can someone help me with it?
My current procedure looks as follows:
DECLARE @CrsrBankVar CURSOR
DECLARE @CrsrCashVar CURSOR
/* Execute the procedure created earlier to fill the variable. */
EXEC OpenBKCrsr @BKNoMatch = @CrsrBankVar OUTPUT
EXEC OpenCBCrsr @CBNoMatch = @CrsrCashVar OUTPUT
/* Declaring variables to store data from cursor @CrsrBankVar */
DECLARE @BkDate as decimal(9,0),
@BkAmt as decimal(9,3)
/* Use the variable to fetch the rows from the cursor. */
FETCH NEXT FROM @CrsrBankVar INTO @BkDate, @BkAmt
WHILE (@@FETCH_STATUS = 0)
BEGIN
**************************
Here I want to compare each row from @CrsrCashVar with the
variables defined above
**** Need help to do so ***********
**************************
print @BkDate
print @BkAmt
PRINT '****************'
FETCH NEXT FROM @CrsrBankVar
END
CLOSE @CrsrBankVar
CLOSE @CrsrCashVar
DEALLOCATE @CrsrBankVar
DEALLOCATE @CrsrCashVar
GO