High rookiedba,
if you COMMIT WORK, you must first FETCH a row before you can do a DELETE WHERE CURRENT OF.
so if your logic is:
FETCH CURSOR
loop:
if n DELETES done then COMMIT
DELETE WHERE CURRENT OF CURSOR
FETCH CURSOR
end loop
you will receive an SQLCODE -508
an other reason for -508 might be:
Two Deletes without a new fetch
FETCH CURSOR
DELETE WHERE CURRENT OF CURSOR
DELETE WHERE CURRENT OF CURSOR
third reason might be:
if the row, the cursor currently refers to, is deleted by an other statement ( or even by a cascading delete ).
your problem might also be a logic like:
FETCH parent-cursor
FETCH child-cursor
DELETE WHERE CURRENT OF child-cursor
COMMIT
DELETE WHERE CURRENT OF parent-cursor
as mentioned above, after a commit a new fetch is necessary before issuing a DELETE WHERE CURRENT OF.
So changing the logic might help:
FETCH parent-cursor
FETCH child-cursor
DELETE WHERE CURRENT OF child-cursor
DELETE WHERE CURRENT OF parent-cursor
COMMIT