SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Static Rowsets
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
7-10
Selecting Rows Into Rowset Arrays
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:
DDL: create table rownum1(a int, b int, primary key(a));