Probably a year ago I asked for recommendations of how to use alternative code 
for a cursor that had to go through 50,000 rows of data, run hundreds of lines 
of code per record, and would periodically lock up.  I got a couple examples, 
and I picked this one as being the easiest to follow, the simplest and best of 
all, IT WORKS!   I forgot who gave it to me, but thank you!   And perhaps this 
will help someone else.

Karen

DROP CURSOR c1
DECLARE c1 CURSOR FOR SELECT  ....... blah blah blah
OPEN c1

LABEL GetCursor

FETCH c1 INTO ..... blah blah blah

IF SQLCODE = 100 THEN
  GOTO EndCursor  
ENDIF

-- do all your processing here

GOTO GetCursor


LABEL EndCursor
WRITE 'I AM DONE!'


RETURN


Reply via email to