0

I have this stored procedure T1 which returns a refcursor.

create procedure t1(inout rr refcursor)
as $$
begin
open rr for select 'receiving it';
end;
$$ language plpgsql;

Another stored procedure t_main calls T1 and it needs to return the same refcursor result set of T1.

create or replace procedure t_main(inout rc refcursor)
as
$$
declare
rc_in refcursor;
begin
call t1(rc_in);
rc := rc_in;
end;
$$
language plpgsql;

The part rc := rc_in; is not passing the refcursor rc_in to rc. When I execute t_main, I get error saying cursor 'rc' does not exist.

Thanks in advance.

1 Answer 1

1

The solution is as below

create or replace procedure t_main(inout rc refcursor)
as
$$
begin
call t1(rc );
end;
$$
language plpgsql;

Using the same refcursor parameter of the main procedure in the dependent procedure solved the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.