SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)
Exception Handling and Error Conditions
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL—663854-005
13-12
Viewing the SQL Messages
Viewing the SQL Messages
To view a list of all SQL messages, see the appropriate messages manual.
The message key is a sequential SQL/MX message number that is returned
automatically by NonStop SQL/MX when an error condition occurs. For example, this
error message might be displayed within your application development tool while it is
preparing an embedded SQL program:
*** ERROR[1000] A syntax error occurred.
This message number is the SQLCODE value (without the sign). You can view the
message for ERROR[1000]:
SQL 1000
Cause. Syntax was entered incorrectly.
Effect. SQL is unable to prepare the statement.
Recovery. Correct the syntax error and resubmit.
The second number, if present, is the corresponding SQL:1999 SQLSTATE value. In
this example, SQLSTATE 42000 is an ANSI value.
Within MXCI, you can display text associated with a message number or SQLCODE
value by using the ERROR command. For further information, see the ERROR
Command in the SQL/MX Reference Manual.
Accessing SQL Messages Within a Program
To obtain error messages that result from the execution of an SQL statement within a
program, use the GET DIAGNOSTICS statement to access the SQL diagnostics area.
For example, you might code your program to display:
SQLSTATE: 22001
SQLCODE : -8402
Message : *** ERROR[8402] A string overflow occurred during
the evaluation of a character expression.
The corresponding fields in the diagnostics area are RETURNED_SQLSTATE,
SQLCODE, and MESSAGE_TEXT, respectively. The message text also provides the
SQL message number.
See Accessing and Using the Diagnostics Area
on page 13-17.
1000 42000 A syntax error occurred.










