Rosh
Rosh

Reputation: 731

Get result set from stored procedure postgresql 11

I want to get results set from a stored procedure (not a function) in PostgreSQL 11 version. I wrote below the stored procedure. But I couldn't get results set from that. Please help anyone!

CREATE OR REPLACE PROCEDURE sp_address (INOUT _result_one refcursor = 'rs_resultone') language 
plpgsql
as $$
BEGIN
     OPEN _result_one FOR SELECT city, country FROM address;
END $$;

I executed the stored procedure as below.

BEGIN;
CALL sp_address('sss');
FETCH ALL FROM "rs_resultone";
END;

Then I got the below error.

ERROR: cursor "rs_resultone" does not exist SQL state: 34000

Upvotes: 0

Views: 416

Answers (0)

Related Questions