Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2) E25519-09 |
|
|
PDF · Mobi · ePub |
The SELECT
INTO
statement retrieves values from one or more database tables (as the SQL SELECT
statement does) and stores them in variables (which the SQL SELECT
statement does not do).
Caution:
TheSELECT
INTO
statement with the BULK
COLLECT
clause is vulnerable to aliasing, which can cause unexpected results. For details, see "SELECT BULK COLLECT INTO Statements and Aliasing".See:
See "function_call ::=".
Causes the database to return only one copy of each set of duplicate rows selected. Duplicate rows are those with matching values for each select_item
. These two keywords are synonymous.
Restrictions on DISTINCT and UNIQUE
The total number of bytes in all select_item
expressions is limited to the size of a data block minus some overhead. This size is specified by the initialization parameter DB_BLOCK_SIZE
.
No select_item
expression can contain a LOB column.
(Default) Causes the database to return all rows selected, including all copies of duplicates.
Selects all columns.
With this clause, the SELECT
INTO
statement retrieves one or more columns from a single row and stores them in either one or more scalar variables or one record variable. For more information, see "into_clause".
With this clause, the SELECT
INTO
statement retrieves an entire result set and stores it in one or more collection variables. For more information, see "bulk_collect_into_clause".
SQL SELECT
statement (not a PL/SQL SELECT
INTO
statement).
Another (usually short) name for the referenced column, table, or view.
Anything that can follow the FROM
clause in a SQL SELECT
statement, described in Oracle Database SQL Language Reference.
If the SELECT
INTO
statement returns no rows, PL/SQL raises the predefined exception NO_DATA_FOUND
. To guard against this exception, select the result of the aggregate function COUNT(*)
, which returns a single value even if no rows match the condition.
Literal of a numeric data type.
Name of the schema that contains the table or view. Default: your schema.
Name of a database table or view.
Name of a column of db_table_or_view
.
Selects all columns of db_table_or_view
.
Name of a sequence.
Current value in sequence
.
Next value in sequence
.
Another (usually short) name for the referenced column, table, or view.
Reference to a table or view for which you have the SELECT
privilege, which is accessible when you run the SELECT
INTO
statement.
Name of the schema that contains the table or view. Default: your schema.
Name of a database table.
Name of a database view.
PARTITION partition or SUBPARTITION subpartition
See Oracle Database SQL Language Reference.
Database link, described in Oracle Database SQL Language Reference. Do not put space between @ and dblink
.
Example 2-25, "Assigning Value to Variable with SELECT INTO Statement"
Example 5-47, "SELECT INTO Assigns Values to Record Variable"
Example 7-13, "Validation Checks Guarding Against SQL Injection"
Example 12-16, "Bulk-Selecting Two Database Columns into Two Nested Tables"
Example 12-17, "Bulk-Selecting into Nested Table of Records"
Example 12-21, "Limiting Bulk Selection with ROWNUM and SAMPLE"