NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
I-15
INSERT Statement
{ VALUES ( val [, val ] ...) [ insert-opt ] ... }
{ ( select-stmt ) [ insert-opt ] ... }
{ select-stmt }
specifies the values to insert. Include a value for each column specified
previously on the INSERT statement, specify the values in the same order as the
columns, and specify values of appropriate type and size for the corresponding
columns.
val
is a host variable, a literal, an expression, a parameter name, or the keyword
NULL (representing a null value) that specifies a value. val cannot include a
column reference.
select-stmt
specifies a select operation that selects values from other tables or views to
insert in name. It has the syntax of a SELECT statement (see SELECT
Statement on page S-18) with the following restrictions:
The select list must contain an element for each column specified on the
INSERT statement.
The SELECT cannot include a subquery that refers to a table, view, or
underlying table of the view into which rows are being inserted.
The SELECT cannot use the INTO clause.
You must enclose the select-stmt in parentheses if it includes an access
mode. The access mode applies only to rows compared to the selection
criteria (in this case, even if the rows are in an audited table).
If select-stmt returns no rows, no rows are inserted. (Note that this
contrasts with the behavior for subqueries in comparison predicates. For
subqueries, if no values are returned, SQL returns a null value.)
[ FOR ] { STABLE | REPEATABLE } ACCESS
specifies STABLE or REPEATABLE access mode. STABLE is the default. (See
Access Options on page A-1 for more information.)
RETURNING { :host-var }
{ LASTSYSKEY}
{ ?param }
directs SQL to return the value of the SYSKEY for the last record inserted. (Applies
only in host programs that INSERT into tables or views with a SYSKEY column.)