---Create Type to hold data
create or replace type EmpJobs Is Table Of Varchar2(100);
/
---Create Function to generate rows
Create Or Replace Function Depts_Jobs(Vdept Number)
Return Empjobs As
Rec Empjobs := Empjobs();
Cursor c Is
Select Job From Emp Where Deptno = Vdept;
Cntr Number := 0;
Begin
For i In c Loop
Rec.Extend;
Cntr := Cntr + 1;
Rec(Cntr) := i.Job;
End Loop;
Return(Rec);
End;
/
---Execute
Select * From Table(depts_jobs(10));
create or replace type EmpJobs Is Table Of Varchar2(100);
/
---Create Function to generate rows
Create Or Replace Function Depts_Jobs(Vdept Number)
Return Empjobs As
Rec Empjobs := Empjobs();
Cursor c Is
Select Job From Emp Where Deptno = Vdept;
Cntr Number := 0;
Begin
For i In c Loop
Rec.Extend;
Cntr := Cntr + 1;
Rec(Cntr) := i.Job;
End Loop;
Return(Rec);
End;
/
---Execute
Select * From Table(depts_jobs(10));
No comments:
Post a Comment