SQL Programming Manual for TAL

Error and Status Processing
HP NonStop SQL Programming Manual for TAL527887-001
6-2
Using the SQLCODE Variable
Declaring the SQLCODE Variable
Declare SQLCODE in your program as an integer variable:
INT SQLCODE;
If you omit the SQLCODE declaration, the compiler generates an “undeclared
identifier” error. The SQLCODE variable must be declared within scope of the
embedded SQL statement that you will execute. To ensure SQLCODE is always in this
scope, declare SQLCODE as a global variable at the start of each module that
contains embedded SQL statements.
Checking the SQLCODE Variable
Figure 6-1 shows an example that inserts two column values into the PARTS table and
checks for errors using the SQLCODE variable.