| Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2) Part Number E17126-03 |
|
|
View PDF |
The assignment statement sets the value of a data item to a valid value.
Topics:
Syntax

See "expression ::=".
placeholder_expression ::=
Semantics
assignment_statement
collection_variable_name
The name of a collection variable. For information about collection variables, see "Collection Variable".
index
A numeric expression whose value has the data type PLS_INTEGER or a data type that can be implicitly converted to PLS_INTEGER (see "PLS_INTEGER and BINARY_INTEGER Data Types").
Specify index to assign the value of expression to a specific element of the collection variable.
Omit index to assign expression to the entire collection variable.
If collection_variable_name is the name of an associative array, then expression must be the name of a collection variable of the same data type.
If collection_variable_name is the name of a varray or nested table, then expression can be any of the following:
The name of a collection variable of the same data type
A collection constructor for the data type of the target collection variable (for collection constructor syntax, see "collection_constructor ::=")
NULL
Note:
Collections with elements of the same type might not have the same data type. For the syntax of collection type definitions, see "Collection Variable".cursor_variable_name
The name of a cursor variable. For information about cursor variables, see "Cursor Variable Declaration".
host_cursor_variable_name
The name of a cursor variable declared in a PL/SQL host environment and passed to PL/SQL as a bind argument. Do not put space between the colon (:) and host_cursor_variable_name.
The data type of a host cursor variable is compatible with the return type of any PL/SQL cursor variable.
object_name
The name of an instance of an ADT. For general information about ADTs, see "Abstract Data Types".
attribute_name
The name of an attribute of object_name.
parameter_name
The name of a formal OUT or IN OUT parameter of the subprogram in which the assignment statement appears. For information about formal parameters, see "Formal Parameter Declaration".
record_variable_name
The name of a record variable. For information about record variables, see "Record Variable Declaration".
field_name
The name of a field in record_name.
Specify field_name to assign the value of expression to a specific field of record_name.
Omit field_name to assign the value of expression to all fields of record_name simultaneously; that is, to assign one record to another. You can assign one record to another only if their declarations refer to the same table or cursor.
scalar_variable_name
The name of a PL/SQL scalar variable. For information about scalar variables, see "Scalar Variable Declaration".
expression
The expression whose value is to be assigned to the target (the item to the left of the assignment operator) when the assignment statement runs.
The value of expression must have a data type that is compatible with the data type of the target. If the target is a collection variable, then the value of expression must be a collection of the same data type (see "Assigning Values to Collection Variables"). If the target is a record variable, then the value of expression must be a record of the same data type (see "Assigning One Record Variable to Another"). If the target has constraints, the value of expression cannot violate them.
For general information about expressions, see "Expression".
placeholder_expression
host_variable
The name of a variable declared in a PL/SQL host environment and passed to PL/SQL as a bind argument. Do not put space between the colon (:) and host_variable_name.
indicator_variable
The name of an indicator variable declared in a PL/SQL host environment and passed to PL/SQL as a bind argument. An indicator variable indicates the value or condition of its associated host variable (for example, in the Oracle Precompiler environment, an indicator variable can a detect null or truncated value in an output host variable). Do not put space between host_variable_name and the colon (:) or between the colon and indicator_name. This is correct:
:host_variable_name:indicator_name
Examples
Example 2-24, "Assigning Values to Variables with Assignment Statement"
Example 5-7, "Data Type Compatibility for Collection Assignment"
Related Topics
In this chapter:
In other chapters: