I have pulled very simple code from IBM manual which demonstrates a simple test to determine cursor status (and I gather, avoid either -501 or -502 SQLCODES).
IF READCUR IS OPEN
EXEC SQL
CLOSE READCUR
END-EXEC
EXEC SQL
OPEN READCUR
END-EXEC
ELSE
EXEC SQL
OPEN READCUR
END-EXEC
END-IF
READCUR is defined in WS:
EXEC SQL
DECLARE READCUR CURSOR FOR
SELECT
etc.etc.
But at compile time the compiler throws a '14' return and says READCUR is undefined. The program is an old one and has run for years
but my attempt to insert the test for open cursor is stymied.
Is it that my DB2 / COBOL environment doesn't allow using DB2 predicates (at least for a cursor) ?