Execute an INSERT that is associated with a cursor

You can also use an sqlda structure to handle an INSERT that is associated with an insert cursor. In this case, you do not execute the statement with the EXECUTE...USING DESCRIPTOR statement. Instead, you must declare and open an insert cursor and execute the insert cursor with the PUT...USING DESCRIPTOR statement, as follows:
  1. Prepare the INSERT statement and associate it with an insert cursor with the DECLARE statement. All multirow INSERT statements must have a declared insert cursor.
  2. Create the cursor for the INSERT statement with the OPEN statement.
  3. Insert the first set of column values into the insert buffer with a PUT statement and its USING DESCRIPTOR clause. After this PUT statement, the column values stored in the specified sqlda structure are stored in the insert buffer. Repeat the PUT statement within a loop until there are no more rows to insert.
  4. After all the rows are inserted, exit the loop and flush the insert buffer with the FLUSH statement.
  5. Close the insert cursor with the CLOSE statement.

You handle the insert cursor in much the same way as you handle the cursor associated with a SELECT statement. For more information about how to use an insert cursor, see the PUT statement in the Informix® Guide to SQL: Syntax.