Thursday, September 15, 2011

ANCHORED DECLERATIONS

PL/SQL offers two kinds of achoring.
Ø  Scalar anchoring
Ø  Record anchoring

SCALAR ANCHORING

Use the %TYPE attribute to define your variable based on table’s column of some other PL/SQL scalar variable.
Ex:
                        DECLARE
                              dno dept.deptno%type;
                              Subtype t_number is number;
                           a t_number;
                              Subtype t_sno is student.sno%type;
                              V_sno t_sno;

RECORD ANCHORING

Use the %ROWTYPE attribute to define your record structure based on a table.
Ex:
                        DECLARE
                                V_dept dept%rowtype;

BENEFITS OF ANCHORED DECLARATIONS

Ø  Synchronization with database columns.
Ø  Normalization of local variables.

No comments:

Post a Comment

Oracle Escape Characters

Oracle allows the assignment of special escape characters to tell Oracle that the character is interpreted literally.  Certain characters ...