Nested type Collection.
0
Nested type Collection:
TYPE type_name IS RECORD
(EmpRecord Emp%ROWTYPE,
DeptRecord dept%ROWTYPE,
Element RECORD);
SQL>DECLARE
TYPE pf_info is RECORD
(pfno NUMBER(4),
amount NUMBER(14,2));
TYPE emp_res IS RECORD
(eid NUMBER(4),
name VARCHAR2(20),
basic NUMBER(12,2),
pf pf_info);
TYPE etab IS TABLE OF emp_rec
INDEX BY BINARY_INTEGER;
ctr NUMBER(3):=1;
e etab;
BEGIN
FOR i IN(SELECT empno,ename,sal basic,
Sal*0.12 pamt FROM emp
WHERE sal>2000)
LOOP
e(ctr).eid:=i.empno;
e(ctr).name:=i.ename;
e(ctr).basic:=i.basic;
e(ctr).pf.pfno:=i.empno+5;
e(ctr).pf.amount:=i.pamt;
ctr:=ctr+1;
END LOOP;
display(‘employee detailes are:’);
FOR MyIndex in 1..e.count
loop
display(e(MyIndex).eid||’ ‘||e(MyIndex).name||’ ‘||e(MyIndex).basic||’ ‘||e(MyIndex).pf.pfno||’ ‘||e(MyIndex).pf.amount);
END LOOP;
END;
TYPE type_name IS RECORD
(EmpRecord Emp%ROWTYPE,
DeptRecord dept%ROWTYPE,
Element RECORD);
SQL>DECLARE
TYPE pf_info is RECORD
(pfno NUMBER(4),
amount NUMBER(14,2));
TYPE emp_res IS RECORD
(eid NUMBER(4),
name VARCHAR2(20),
basic NUMBER(12,2),
pf pf_info);
TYPE etab IS TABLE OF emp_rec
INDEX BY BINARY_INTEGER;
ctr NUMBER(3):=1;
e etab;
BEGIN
FOR i IN(SELECT empno,ename,sal basic,
Sal*0.12 pamt FROM emp
WHERE sal>2000)
LOOP
e(ctr).eid:=i.empno;
e(ctr).name:=i.ename;
e(ctr).basic:=i.basic;
e(ctr).pf.pfno:=i.empno+5;
e(ctr).pf.amount:=i.pamt;
ctr:=ctr+1;
END LOOP;
display(‘employee detailes are:’);
FOR MyIndex in 1..e.count
loop
display(e(MyIndex).eid||’ ‘||e(MyIndex).name||’ ‘||e(MyIndex).basic||’ ‘||e(MyIndex).pf.pfno||’ ‘||e(MyIndex).pf.amount);
END LOOP;
END;
0 comments: