INSERT
The INSERT statement allows you to add new rows into a table.
General format
EXEC SQL [ AT Database ] [ FOR Iterations ] INSERT Options [ VALUES ( { Insert-Value } ... ) ] [ RETURNING Field ... INTO HostVariable ... ] END-EXEC |
Syntax rules
1. Iterations can be either a host variable or a numeric literal. It specifies the number of rows to be processed.
2. Options is passed to the driver without further checks. Refer to the database documentation for detailed syntax. Syntax errors, if any, are returned at runtime.
4. Field is a alphanumeric literal.
General rules
1. When
Insert-Value is a
host variable declared as a group-item, the runtime uses all subordinate items as separate values instead of using the group-item as a single value.
2. The FOR clause limits the number of times the statement is executed when Insert-Value are array host variables. If you omit this clause,it executes the statement once for each component of the smallest array.
3. Database identifies the active connection that will execute the query and must be previously defined using a Format 4
DECLARE statement.
4. The RETURNING clause allows you to receive the updated fields value into host variables.
Examples
Inserting rows on a customers table
exec sql insert into customers values (10, 'Adam Smith') end-exec exec sql insert into customers values (20, 'Eve Scott') end-exec |