SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)
Static Rowsets
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL—663854-002
7-9
Selecting Rows Into Rowset Arrays
At the beginning of the execution of an SQL statement, the diagnostics area is
emptied. When the statement executes, NonStop SQL/MX places information on
completion or exception conditions into this area. The diagnostics area consists of:
Statement information: Header area with information on the SQL statement as a
whole
Condition information: Detail area with information on each error, warning, or
completion code that occurs during the execution of the SQL statement
The number of retrieved rows is stored in the ROW_COUNT field of the statement
information in the diagnostics area. You can retrieve the value in the ROW_COUNT
field by using the GET DIAGNOSTICS statement. In the preceding example, the
statement that retrieves the value of ROW_COUNT is specified as:
EXEC SQL GET DIAGNOSTICS :numrows = ROW_COUNT;
For further information, see the GET DIAGNOSTICS statement in the SQL/MX
Reference Manual.
Retrieving the Row Number for a Failed Operation
NonStop SQL/MX returns an error when an INSERT or UPDATE operation using a
rowset fails. The row number causing the error can be retrieved.
NonStop SQL/MX stores completion and exception information for an embedded SQL
statement in the diagnostics area. NonStop SQL/MX automatically allocates this area
in memory.
The diagnostics area is empty before you execute an SQL statement. When you
execute the statement, NonStop SQL/MX places the information about completion or
exception conditions into the diagnostics area. The diagnostics area consists of the
following:
Statement Information: The header area that contains information about the SQL
statement.
Condition Information: The detail area that contains information on errors,
warnings, or completion codes that occur during the execution of the SQL
statement.
The row number that causes the error in an INSERT or UPDATE operation is stored in
the field ROW_NUMBER in the statement information of the diagnostics area. You can
retrieve the value in the field ROW_NUMBER by using the GET DIAGNOSTICS
statement.
For more information, see the GET DIAGNOSTICS statement in the SQL/MX Release
3.2 Reference Manual.
Example
The following example retrieves the row number that causes the error in the insert
operation which is stored in the ROW_NUMBER field of the diagnostics area:










