Icon INSERT

Inserts a new row into a result set cursor.

Syntax
INSERT INTO <CursorName>
[(<ColumnName> [,<ColumnName>])]
VALUES (<Value> [,<Value>])

Usage
Use this statement to insert a new row into a result set cursor. If a list of columns to populate is not specified, then the number of values specified in the VALUES clause must match the number of columns in the result set that the cursor is using. All values specified in the VALUES clause must be type-compatible with the specified columns, or all of the columns in the result set if the columns are not specified.

Examples
-- This procedure checks to see if the
-- specified State exists in the States lookup
-- table and inserts it if it isn't

CREATE PROCEDURE LookupState(IN StateParam CHAR(2) COLLATE ANSI_CI)
BEGIN
   DECLARE StateCursor SENSITIVE CURSOR FOR Stmt;

   PREPARE Stmt FROM 'SELECT * FROM States WHERE State = ?';

   OPEN StateCursor USING StateParam;

   IF (ROWCOUNT(StateCursor) = 0) THEN
      INSERT INTO StateCursor ('State') VALUES (StateParam);
   END IF;

   CLOSE StateCursor;   

END

Required Privileges
If the result set cursor is a sensitive cursor, then the current user must be granted the INSERT and SELECT privileges on the table in the SELECT statement used to output the result set that the cursor is using. Please see the User Security topic for more information.

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis SQL statement is an ElevateDB extension.
Image