Skip Headers
Oracle® Database PL/SQL Language Reference
11g Release 2 (11.2)

Part Number E25519-05
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub
LNPLS01345

SELECT INTO Statement

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:

The SELECT 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 Also:

Oracle Database SQL Language Reference for the syntax of the SQL SELECT statement

LNPLS1820Topics

Syntax

LNPLS1325select_into_statement ::=

Description of select_into_statement.gif follows
Description of the illustration select_into_statement.gif

See:

LNPLS1326select_item ::=

Description of select_item.gif follows
Description of the illustration select_item.gif

See "function_call ::=".

LNPLS1327table_reference ::=

Description of table_reference.gif follows
Description of the illustration table_reference.gif

Semantics

LNPLS1821select_into_statement

LNPLS1822DISTINCT or UNIQUE

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.

LNPLS1823Restrictions on DISTINCT and UNIQUE 

LNPLS1824ALL

(Default) Causes the database to return all rows selected, including all copies of duplicates.

LNPLS1825*

Selects all columns.

LNPLS1826into_clause

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".

LNPLS1329bulk_collect_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".

LNPLS1338subquery

SQL SELECT statement (not a PL/SQL SELECT INTO statement).

LNPLS1328alias

Another (usually short) name for the referenced column, table, or view.

LNPLS1336rest_of_statement

Anything that can follow the FROM clause in a SQL SELECT statement, described in Oracle Database SQL Language Reference.

LNPLS1827select_item

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.

LNPLS1828numeric_literal

Literal of a numeric data type.

LNPLS1337schema

Name of the schema that contains the table or view. Default: your schema.

LNPLS1829db_table_or_view

Name of a database table or view.

LNPLS1830column

Name of a column of db_table_or_view.

LNPLS1831*

Selects all columns of db_table_or_view.

LNPLS1832sequence

Name of a sequence.

LNPLS1833CURRVAL

Current value in sequence.

LNPLS1834NEXTVAL

Next value in sequence.

LNPLS1835alias

Another (usually short) name for the referenced column, table, or view.

LNPLS1836table_reference

Reference to a table or view for which you have the SELECT privilege, which is accessible when you run the SELECT INTO statement.

LNPLS1837schema

Name of the schema that contains the table or view. Default: your schema.

LNPLS1838table

Name of a database table.

LNPLS1839view

Name of a database view.

LNPLS1840PARTITION partition or SUBPARTITION subpartition

See Oracle Database SQL Language Reference.

LNPLS1841@dblink

Database link, described in Oracle Database SQL Language Reference. Do not put space between @ and dblink.

Examples

Related Topics

LNPLS1842In this chapter:

LNPLS1843In other chapters:

See Also:

Oracle Database SQL Language Reference for information about the SQL SELECT statement
Reader Comment

   

Comments, corrections, and suggestions are forwarded to authors every week. By submitting, you confirm you agree to the terms and conditions. Use the OTN forums for product questions. For support or consulting, file a service request through My Oracle Support.

Hide Navigation

Quick Lookup

Database Library · Master Index · Master Glossary · Book List · Data Dictionary · SQL Keywords · Initialization Parameters · Advanced Search · Error Messages

Main Categories

This Document

New and changed documents:
RSS Feed HTML RSS Feed PDF