Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements > FETCH >

Checking the Result of FETCH

You can use the SQLSTATE variable to check the result of each FETCH statement. The database server sets the SQLSTATE variable after each SQL statement. If a row is returned successfully, the SQLSTATE variable contains the value 00000. If no row is found, the database server sets the SQLSTATE code to 02000, which indicates no data found, and the current row is unchanged. The following conditions set the SQLSTATE code to 02000, indicating no data found:

The database server copies the SQLSTATE code from the RETURNED_SQLSTATE field of the system-diagnostics area. You can use the GET DIAGNOSTICS statement to examine the RETURNED_SQLSTATEfield directly. The system-diagnostics area can also contain additional error information.

You can also use SQLCODE variable of the SQL Communications Area (sqlca) to determine the same results.

Related Information

Related statements: ALLOCATE DESCRIPTOR, CLOSE , DEALLOCATE DESCRIPTOR, DECLARE , DESCRIBE, GET DESCRIPTOR , OPEN , PREPARE, SET DEFERRED_PREPARE, and SET DESCRIPTOR

For a task-oriented discussion of the FETCH statement, see the IBM Informix Guide to SQL: Tutorial.

For more information about concepts that relate to the FETCH statement, see the IBM Informix ESQL/C Programmer's Manual.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]