The %TYPE
attribute lets you declare a constant, variable, field, or parameter to be of the same data type a previously declared variable, field, record, nested table, or database column. If the referenced item changes, your declaration is automatically updated.
An item declared with %TYPE
(the referencing item) always inherits the data type of the referenced item. The referencing item inherits the constraints only if the referenced item is not a database column. The referencing item inherits the default value only if the referencing item is not a database column and does not have the NOT
NULL
constraint.
Keyword and Parameter Descriptions
A nested table, index-by table, or varray previously declared within the current scope.
A PL/SQL cursor variable previously declared within the current scope. Only the value of another cursor variable can be assigned to a cursor variable.
A table and column that must be accessible when the declaration is elaborated.
An instance of an object type, previously declared within the current scope.
A user-defined or %ROWTYPE
record, previously declared within the current scope.
A field in a user-defined or %ROWTYPE
record, previously declared within the current scope.
A variable, previously declared in the same scope.
Example 2-10, "Using %TYPE to Declare Variables of the Types of Other Variables"
Example 2-11, "Using %TYPE Incorrectly with NOT NULL Referenced Type"
Example 2-12, "Using %TYPE Correctly with NOT NULL Referenced Type"
Example 2-13, "Using %TYPE to Declare Variables of the Types of Table Columns"
Example 2-17, "Assigning One Record to Another, Correctly and Incorrectly"
Example 5-5, "Declaring a Procedure Parameter as a Nested Table"
Example 5-7, "Specifying Collection Element Types with %TYPE and %ROWTYPE"