0

I am try to make a cursor with loop condition. purpose of cursor:- I want to execute a procedure 17times .

Procedure definition:

dbo.ALLAARTI_MIS_SUMMARY @IN_SYSDIFF = @IN_DIFF

DECLARE @IN_DIFF int
DECLARE vendor_cursor CURSOR FOR
SELECT date_time FROM dumy_mis  
OPEN vendor_cursor

FETCH NEXT FROM vendor_cursor   
INTO @IN_DIFF

WHILE @@FETCH_STATUS = 0
BEGIN
exec dbo.ALLAARTI_MIS_SUMMARY @IN_SYSDIFF = @IN_DIFF
END
CLOSE vendor_cursor  
DEALLOCATE vendor_cursor
  • Dear Jay execution in PLSQL – surendra Nov 28 '17 at 9:42
  • ANY ONE CAN SUGGEST – surendra Nov 28 '17 at 10:08
  • any one can help – surendra Nov 28 '17 at 10:23
1

I'm not sure what are you trying to achieve with this script, but you should fetch next records inside WHILE block just to be sure that @@FETCH_STATUS=0

dbo.ALLAARTI_MIS_SUMMARY @IN_SYSDIFF = @IN_DIFF

DECLARE @IN_DIFF int
DECLARE vendor_cursor CURSOR FOR
SELECT date_time FROM dumy_mis  
OPEN vendor_cursor

FETCH NEXT FROM vendor_cursor   
INTO @IN_DIFF

WHILE @@FETCH_STATUS = 0
BEGIN
    exec dbo.ALLAARTI_MIS_SUMMARY @IN_SYSDIFF = @IN_DIFF

    FETCH NEXT FROM vendor_cursor   
    INTO @IN_DIFF
END
CLOSE vendor_cursor  
DEALLOCATE vendor_cursor
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.