Tuesday, August 6, 2019

Describe the use of %ROWTYPE and %TYPE in PL/SQL

%ROWTYPE is used to associate a variable with an entire table row.
it provides the data type of a variable or a database column to that variable.


Syntax :%TYPE attribute


Ex.              DECLARE
                     books_printed         NUMBER (6);
                      books_sold             books_printed%TYPE ;
                      maiden_name         emp.ename%TYPE ;

%TYPE is used to associates a variable with a single column type.
it provides the record type that represents a entire row of a table or view or columns selected in the cursor.

Syntax : %ROWTYPE attribute
Ex.               DECLARE
                     dept_row     dept%ROWTYPE ;
Advantages

  1. need not know about variable's data type.
  2. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
PL/SQL objects (such as variables and constants) and database objects(such as col. and tables )are associated with certain attributes.

No comments:

Post a Comment

AME (Approval Management Engine)

AME (Approval Management Engine) : AME Stands for Oracle Approval Management Engine. AME is a self service web application that enables...