SQL/MX Comparison Guide for SQL/MP Users
Embedded SQL
HP NonStop SQL/MX Comparison Guide for SQL/MP Users—523735-003
4-8
Error Handling
DESCRIPTOR statements. After the parameters have been described (by using the
DESCRIBE statement as in NonStop SQL/MP), you can modify and retrieve
information from the descriptor areas only by using the SET DESCRIPTOR and GET
DESCRIPTOR statements, respectively.
If you have dynamic input parameters in a prepared SQL statement, you must code the
appropriate 3GL statements and use SET DESCRIPTOR to set the values in the
descriptor area. If you have more than one dynamic input parameter, you can identify
the values by their position in the prepared SQL statement. If you are using descriptor
areas for input parameters, you must use the CAST specification to specify the
appropriate data type.
In NonStop SQL/MX, you should give input parameters a defined data type provided in
the descriptor area by using the CAST specification. The CAST specification is not
needed for MXCI parameters or for parameters used in dynamic cursors in embedded
SQL programs.
For examples that use dynamic SQL statements, see the SQL/MX Reference Manual.
Error Handling
The major difference in error handling between NonStop SQL/MP and NonStop
SQL/MX relates to the SQL:1999 standard, as described next.
Format of Error Codes
NonStop SQL/MP provides an integer-valued SQLCODE as the mechanism to send
error information from the database to the application.
NonStop SQL/MX supports both an SQLCODE mechanism and the new SQLSTATE
codes, as specified in the SQL:1999 standard. However, the SQLCODE values
generated by NonStop SQL/MX are different from those generated by NonStop
SQL/MP. For portable applications, you should use SQLSTATE. Because of the
overhead associated with SQLSTATE, you will most likely use it only for error handling
in ANSI-compliant applications. For information about SQLSTATE and error handling in
NonStop SQL/MX, see the SQL/MX Programming Guide for C and COBOL.
Equivalent SQLCODE and SQLSTATE Values
Error
NonStop
SQL/MP
SQLCODE
NonStop
SQL/MX
SQLCODE
NonStop
SQL/MX
SQLSTATE
SQL_NO_ERROR 0 0 00000
SQL_NO_ROWS_MATCH 100 100 02000
SQL_TOO_MANY_MEET_CRITERIA -8222 -8401 21000
SQL_DUPLICATE_ENTRY -8227 -8102 23000