Refcursor : is used for return multiple rows & used to process a sql statement .
Task : Used in Function & Stored Procedure
create or replace procedure sp_return_data(inout r1 refcursor,inout r2 refcursor)
language plpgsql
as
$$
begin
open r1 for select * from employee;
open r2 for select * from emp_salary;
end
$$
Begin ;
call sp_return_data(null,null)
fetch all in "<unnamed portal 19>";
fetch all in "<unnamed portal 20>";
commit
create or replace function fn_return_data()
returns refcursor
language plpgsql
as
$$
declare r1 refcursor;
begin
open r1 for select * from employee;
return r1;
end
$$
begin;
select fn_return_data();
fetch all in "<unnamed portal 23>"
commit ;
No comments:
Post a Comment