Download Informix Guide to SQL: Tutorial

Transcript
SQLERRD Array
The second situation involves a query that does not use a cursor. In this case,
the database server sets SQLCODE to 100 when no rows satisfy the query
condition. In databases that are not ANSI compliant, only a SELECT statement
that returns no rows causes SQLCODE to be set to 100.
ANSI
In ANSI-compliant databases, SELECT, DELETE, UPDATE, and INSERT statements all set SQLCODE to 100 if no rows are returned. ♦
Negative Codes
When something unexpected goes wrong during a statement, the database
server returns a negative number in SQLCODE to explain the problem. The
meanings of these codes are documented in the on-line error message file.
SQLERRD Array
Some error codes that can be reported in SQLCODE reflect general problems.
The database server can set a more detailed code in the second field of
SQLERRD that reveals the error that the database server I/O routines or the
operating system encountered.
The integers in the SQLERRD array are set to different values following
different statements. The first and fourth elements of the array are used only
in Informix ESQL/C. Figure 7-3 on page 7-11 shows how the fields are used.
These additional details can be useful. For example, you can use the value in
the third field to report how many rows were deleted or updated. When your
program prepares an SQL statement that the user enters, and an error is
found, the value in the fifth field enables you to display the exact point of
error to the user. (DB-Access and the Relational Object Manager use this
feature to position the cursor when you ask to modify a statement after an
error.)
7-10
Informix Guide to SQL: Tutorial