NOT FOUND in SQLSTATE
"02000"
(class
= "02"
). The following table lists the conditions
that cause SQL statements to yield NOT FOUND. SQL statement that generates the indicated SQLSTATE result | Result for ANSI-compliant database | Result for non-ANSI-compliant database |
---|---|---|
FETCH statement: the last qualifying row has already been returned (the end of data was reached). | "02000" | "02000" |
SELECT statement: no rows match the SELECT criteria. | "02000" | "02000" |
DELETE and DELETE...WHERE statement (not part of multistatement PREPARE): no rows match the DELETE criteria. | "02000" | "00000" |
INSERT INTO tablename SELECT statement (not part of multistatement PREPARE): no rows match the SELECT criteria. | "02000" | "00000" |
SELECT... INTO TEMP statement (not part of multistatement PREPARE): no rows match the SELECT criteria. | "02000" | "00000" |
UPDATE and UPDATE...WHERE statement (not part of multistatement PREPARE): no rows match the UPDATE criteria. | "02000" | "00000" |
SQLSTATE values that are set when SQL statements do not return any rows shows that the value that the NOT FOUND condition generates depends, in some cases, on whether the database is ANSI compliant.
To check
for the NOT FOUND condition, your code needs to verify only the class
code of SQLSTATE. The subclass code is always "000"
.
The getdiag sample program in Guide to the getdiag.ec file uses the sqlstate_err() function
to perform exception handling. To check for a warning in an SQL statement, sqlstate_err() compares
the first two characters of SQLSTATE with the string "02"
.