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

Error Checking FLUSH Statements

The SQL Communications Area (sqlca) structure contains information on the success of each FLUSH statement and the number of rows that are inserted successfully. The result of each FLUSH statement is described in the fields of the sqlca: sqlca.sqlcode, SQLCODE, and sqlca.sqlerrd[2].

When you use data buffering with an insert cursor, you do not discover errors until the buffer is flushed. For example, an input value that is incompatible with the data type of the column for which it is intended is discovered only when the buffer is flushed. When an error is discovered, any rows in the buffer that are located after the error are not inserted; they are lost from memory.

The SQLCODE field is set either to an error code or to zero (0) if no error occurs. The third element of the SQLERRD array is set to the number of rows that are successfully inserted into the database:

Tip:
When you encounter an SQLCODE error, a corresponding SQLSTATE error value also exists. For information about how to get the message text, check the GET DIAGNOSTICS statement.
To count the number of rows actually inserted into the database as well as the number not yet inserted
  1. Prepare two integer variables, for example, total and pending.
  2. When the cursor opens, set both variables to 0.
  3. Each time a PUT statement executes, increment both total and pending.
  4. Whenever a FLUSH statement executes or the cursor is closed, subtract the third field of the SQLERRD array from pending.

Related Information

Related statements: CLOSE , DECLARE , OPEN , and PREPARE

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

For information about the sqlca structure, see the IBM Informix ESQL/C Programmer's Manual.

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