1.

What is the importance of %TYPE and %ROWTYPE data types in PL/SQL?

Answer»
  • %TYPE: This declaration is USED for the purpose of anchoring by PROVIDING the data type of any VARIABLE, column, or constant. It is useful during the declaration of a variable that has the same data type as that of its table column.
    • Consider the example of declaring a variable named ib_employeeid which has the data type and its size same as that of the column employeeid in table ib_employee. 
      The syntax would be : ib_employeeid ib_employee.employeeid%TYPE;
  • %ROWTYPE: This is used for declaring a variable that has the same data type and size as that of a ROW in the table. The row of a table is called a record and its fields would have the same data types and names as the COLUMNS defined in the table.
    • For example: In order to declare a record named ib_emprecord for storing an entire row in a table called ib_employee, the syntax is:
      ib_emprecord ib_employee%ROWTYPE;


Discussion

No Comment Found