6. Working with Transactions and Handling Errors : Ways to Obtain Status Information : SQLCODE and SQLSTATE : SQLCODE Variable
 
Share this page                  
SQLCODE Variable
SQLCODE is an integer variable in which the DBMS returns the status of the last SQL statement executed. For details about the requirements for declaring the SQLCODE variable in embedded programs, see the Embedded SQL Companion Guide.
Note:  The ANSI Entry SQL-92 specification describes SQLCODE as a deprecated feature, and recommends using the SQLSTATE variable.
Values Returned by SQLCODE
The values returned in the standalone SQLCODE variable are the same as those returned in the sqlcode member of the SQLCA structure. The value of SQLCODE is meaningful only in the context of a session.
The values returned in SQLCODE are listed in the following table:
Value
Description
0
Successful completion.
+100
No rows were processed by a DELETE, FETCH, INSERT, SELECT, UPDATE, MODIFY, COPY, CREATE INDEX, or CREATE AS...SELECT statement. This value (+100) sets the not found condition of the WHENEVER statement.
+700
A message statement in a database procedure has just executed, setting the sqlmessage condition of the WHENEVER statement.
+710
A database event was raised.
Negative Value
An error occurred. The value of SQLCODE is the negative value of the error number returned to errorno. For information on errorno, see Error Checking Using Inquire Statements (see Error Checking Using Inquire Statements). A negative value sets the sqlerror condition of the WHENEVER statement.