PL/SQL User's Guide and Reference

Contents Index Home Previous Next

%TYPE Attribute

Description

The %TYPE attribute provides the datatype of a field, record, PL/SQL table, database column, or variable. You can use the %TYPE attribute as a datatype specifier when declaring constants, variables, fields, and parameters. For more information, see "Using %TYPE" [*].

Syntax

type_attribute ::=

{  cursor_variable_name
 | plsql_table_name
 | record_name
 | record_name.field_name
 | table_name.column_name
 | variable_name}%TYPE

Keyword and Parameter Description

cursor_variable_name

This identifies a PL/SQL cursor variable previously declared within the current scope.

plsql_table_name

This identifies a PL/SQL table previously declared within the current scope.

record_name

This identifies a user-defined or %ROWTYPE record previously declared within the current scope.

record_name.field_name

This identifies a field in a user-defined or %ROWTYPE record previously declared within the current scope.

table_name.column_name

This refers to a table and column that must be accessible when the declaration is elaborated.

variable_name

This is the name of a variable previously declared in the same scope. For naming conventions, see "Identifiers" [*].

Usage Notes

The %TYPE attribute is particularly useful when declaring variables, fields, and parameters that refer to database columns. However, the NOT NULL column constraint does not apply to objects declared using %TYPE.

Related Topics

Constants and Variables, %ROWTYPE Attribute


Contents Index Home Previous Next