Execute an INSERT that is associated with a cursor

Your program must still use the DESCRIBE and SET DESCRIPTOR statements (Handling an unknown column list) to use a system-descriptor area for column-list values of an INSERT statement that inserts rows from an insert buffer. It must also use the PUT...USING SQL DESCRIPTOR statement with an insert cursor, 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 SQL DESCRIPTOR clause. After this PUT statement, the column values stored in the specified system-descriptor area 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 (Handling an unknown select list). For more information about how to use an insert cursor, see the PUT statement in the HCL OneDB™ Guide to SQL: Syntax.