Created On:  25 January 2013

Problem:

Customer has a native COBOL application that uses OpenESQL to access a SQL Server database.

The following directives are being used:

SQL(DBMAN=ODBC TARGETDB=MSSQLSERVER BEHAVIOR=MAINFRAME)

The program does a cursor OPEN and then goes into a loop to FETCH all of the rows.
Within this loop, an INSERT is done to a different table followed by a COMMIT.

After the COMMIT is done the next FETCH will result in a SQLCODE=-10000 "Function Sequence Error"

What is causing this?

Resolution:

The default behavior for SQL Server when the SQL(BEHAVIOR=MAINFRAME) directive is used is to close all cursors when the COMMIT is done.

If you require the cursor to remain open after the COMMIT then you should use the SQL(BEHAVIOR=ANSI) directive instead.
Incident #2611096