When the LIBNAME option CONNECTION=SHARED or CONNECTION=GLOBAL is used when accessing DB2 with SAS on z/OS, incorrect results can occur. This occurs when one cursor is open after having read in some data from one DB2 table and a COMMIT is issued for something else. Since both of these cursors were sharing the connection, the COMMIT messes up the cursor that was used for the read.
The following code illustrates one case where rows are not inserted into the new table causing incorrect results:
In this example, right before the table MYNEWCLASS is created, a fetch is executed and a cursor is opened to retrieve the rows from the table CLASS that need to be inserted into the new table. In the meantime, the table MYNEWCLASS is created and a COMMIT is issued. This messes with the data that was present in the cursor so that when the insert is done into MYNEWCLASS not all of the rows that should have been inserted are actually inserted.
This behavior is warned about in the See "CONNECTION= LIBNAME option" in the SAS/ACCESS® 9.2 for Relational Databases: Reference, Fourth Edition.