How can return table of records by using the procedures in plsql
I am writing the procedure as
create or replace procedure my_proc(limit_value in number,.........)
is
cursor...................
.........................
begin
open ...;
loop
.....
.....
close ....;
end my_proc;
I want to generate the reports who are开发者_JAVA技巧 having the salary less than limit value.
Is it possible to get the table records with OUT parameter to generate the reports?
If it is possible, please explain
Yes, you can. You can even do it with the return value of the procedure / function:
create or replace type salary_rec as object (
emp_id number
salary number
);
create or replace type t_salary as table of salary_rec;
create or replace function retrieve_emp(
i_max_salary number
) return t_varchar_number
as
result t_salary;
begin
select salary_rec(emp_id, salary) bulk collect into result
from emp_salary
where salary <= i_max_salary;
return ret;
end;
/
That's just one of many variations of BULK COLLECT and of the different table types in Oralce and PL/SQL.
精彩评论