Problem A program that used to run fine under Net Express has been recompiled using Visual COBOL. The program uses OpenESQL to do a EXEC SQL OPEN on a declared cursor and then proceeds into a loop that fetches each row from the cursor, potentially updating that row and executing an EXEC SQL COMMIT. In Net Express this worked fine but in Visual COBOL the commit statement appears to be closing the cursor because the next fetch after the commit results in a sqlcode = -10000 Function Sequence Error. What can I do to fix this? Resolution: In Net Express the default setting for the SQL(BEHAVIOR) directive was UNOPTIMIZED while in Visual COBOL the default is now MAINFRAME. When BEHAVIOR=MAINFRAME is used the default cursor handling is to close a cursor at the end of a transaction, which is signaled by a COMMIT or ROLLBACK. To change this you can set BEHAVIOR to either UNOPTIMIZED or ANSI and the cursors will no longer be closed. An alternative to this is to use the WITH HOLD phrase when declaring the cursor and then it will always keep the cursor open even when BEHAVIOR is set to MAINFRAME. Example: EXEC SQL DECLARE mycursor CURSOR WITH HOLD FOR... END-EXEC
↧