Determining the attributes of a cursor by using the SQLCA

An SQL communications area (SQLCA) is an area that is set apart for communication with Db2 and consists of a collection of variables. Using the SQLCA is one way to get information about any open cursors. Alternatively, you can use the GET DIAGNOSTICS statement.

About this task

After you open a cursor, you can determine the following attributes of the cursor by checking the following SQLWARN and SQLERRD fields of the SQLCA:

SQLWARN1
Indicates whether the cursor is scrollable or non-scrollable.
SQLWARN4
Indicates whether the cursor is insensitive (I), sensitive static (S), or sensitive dynamic (D).
SQLWARN5
Indicates whether the cursor is read-only, readable and deletable, or readable, deletable, and updatable.
SQLERRD(1) and SQLERRD(2)
These two fields together contain a double-word integer that represents the number of rows in the result table of a cursor when the cursor is positioned after the last row. The cursor is positioned after the last row when the SQLCODE is 100. These fields are not set for dynamic scrollable cursors.
SQLERRD(3)
The number of rows in the result table when the SELECT statement of the cursor contains a data change statement.

If the OPEN statement executes with no errors or warnings, Db2 does not set SQLWARN0 when it sets SQLWARN1, SQLWARN4, or SQLWARN5.