Defining PL/SQL Record.

0
Defining PL/SQL Record:
To define a user defined PL/SQL data type.
  • Type name -> is the name of the Record type.
  • Element  name -> it is the name of the field within the record.
  • Element data type -> it is the data type of the element.
  • Expr -> it is the field type OR a nInitial value.
  • The NOT NULL constraint prevents the assigning of NULL’ s to those fields.
  • Element declaration are like variable declaration each Element has a unique name and a specific data type.
  • We must create the data type first and then declare an identifier using the declared data type.
Illustration:
SQL>DELCARE
                  TYPE erec IS RECORD
                  (veno NUMBER(4),
                  Vname emp.ename%TYPE,
                  Basic emp.sal%TYPE,
                  i dept%ROWTYPE,
                  vgross number(16,2));
                  e erec;
         BEGIN
                  e.veno:=&employe;
                  select ename,sal,dept.deptno,dname into
                  e.vname,e.basic,e.i.deptno,e.i.dname
                  from emp,dept
                  where emp.deptno=dept.deptno and empno=e.vono;
                  e.vgross:=e.basic+e.basic*0.25+e.basic*0.35-e.basic*0.12;
                  display(e.veno||’ ‘||e.basic||’e.i.deptno||’ ‘||e.i.dname||’ ‘||e.vgross);
         END;

About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts