Multiple choice

In a PL/SQL program, to declare a variable with the same data type as a column of a table (anchored declaration), the correct syntax will be

  1. Varname tablename.colname%rowtype

  2. Varname tablename.colname%istype

  3. Varname tablename.colname%totype

  4. Varname tablename.colname%type

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

PL/SQL provides a very useful feature called variable anchors. It refers to the use of keyword %TYPE to declare a variable with the same data type as the column data type in a table. For example, if we want to declare a variable named 'salary' with the same data type as of 'basic_salary' column of a table named 'employee' we can write the following statement: salary employee.basic_salary%type;