The %ROWTYPE attribute provides a record type that represents a row in a database table. Fields in a record and corresponding columns in a row have the same names and data types.
The %ROWTYPE attribute may be used in variable declarations as a data type specifier. Variables declared using %ROWTYPE are treated like those declared using a data type name.
table_name - this identifies a database table (or view) that must be accessible when the declaration is elaborated.
The %ROWTYPE attribute lets declare records structured like a row of data in a database table. To reference a field in the record, you use dot notation. For example,you might reference the deptno field as follows:
The value of an expression may be assign to a specific field, as follows:
Examples:
In the example below, %ROWTYPE is used to store a row selected from the emp table:
emp_rec emp%ROWTYPE;
In the next example, you select a row from the emp table into a %ROWTYPE record:
|