SQL/MX 2.x Database and Application Migration Guide (G06.23+, H06.04+, J06.03+)

Converting SQL/MP Applications to SQL/MX
Applications
HP NonStop SQL/MX Database and Application Migration Guide540435-005
10-49
Error Handling
descriptor area. If you have more than one dynamic input parameter, you can identify
the values by their position in the prepared SQL statement.
In NonStop SQL/MX, use the CAST specification to give input parameters a defined
data type provided in the descriptor area. The CAST specification might improve the
efficiency of the generated query plan. 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 on page 10-49
Equivalent SQLCODE and SQLSTATE Values on page 10-49
WHENEVER Declarative on page 10-52
Diagnostics Area on page 10-53
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, 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
Table 10-13. Mapping SQL/MP SQLCODE to SQL/MX SQLCODE
Values (page1of4)
SQL/MP Error Description
SQL/MP
SQLCODE
SQL/MX
SQLCODE
SQL/MX
SQLSTATE
The operation completed successfully. 0 0 00000
No rows were selected or modified. 100 100 02000
The program corrupted the program file
or an invalid code was generated for the
statement, so the statement failed.
-8030 -8840 X08NC