|
The SELECT (with INTO) statement allows you to select column values from a specified table to insert into variables or to populate a temporary table with data.
SELECT [ ALL | DISTINCT ] select-list INTO variable-or-temp-table-name [ , variable-or-temp-table-name ]... FROM table-reference [ , table-reference ]... [ WHERE search-condition ] [ GROUP BY expression [ , expression ]...[ HAVING search-condition ] ]
The variables must occur within a stored procedure, a trigger, or a user-defined function.
You can populate a temporary table by using SELECT INTO only if the SELECT INTO statement occurs outside of a stored procedure, user-defined function, or trigger. Populating, or creating, a temporary table with SELECT INTO is not permitted within a stored procedure, user-defined function, or trigger.
See the examples for CREATE (temporary) TABLE for how to use SELECT INTO to populate temporary tables. A temporary table can be created and populated with a single SELECT INTO statement.
The following example assigns into variables :x, :y the values of first_name and last_name in the Person table where first name is Bill.
|
Chapter contents
Prev topic: SAVEPOINT
|