Variables Based on Database Columns : TYPE « PL SQL Data Types « Oracle PL/SQL Tutorial






You base a declaration on a table column without having to know definitively what that column's datatype is.

Your variables will automatically be changed as the table column.

You use the %type attribute in variable declarations to define variable based on table column.

avg_rate    employee.pay_rate%type</th>
dept_id     INTEGER;</td>
sub_dept_id dept_id%type;  -- datatype based on a variable</td>
area_id     dept_id%type := 9141; -- used with an initialization clause</td>








21.28.TYPE
21.28.1.Variables Based on Database Columns
21.28.2.PL/SQL allows you to use the %type attribute in a nesting variable declaration.
21.28.3.You may also specify a variable's type using the %TYPE keyword, which tells PL/SQL to use the same type as a specified column in a table.
21.28.4.The %TYPE Command Illustrated
21.28.5.Using %TYPE and %ROWTYPE on Row Objects
21.28.6.Column type parameters
21.28.7.Select value into a column type variable