technical skills grow

Responsive Ads Here

Monday, December 6, 2021

Refcursor in Postgresql

 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

Task : Use refcursor  in function 


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

Powered by Blogger.

Labels

Contact Form

Name

Email *

Message *

Search This Blog

Blog Archive

Ad Code

Responsive Advertisement

Recent Posts