0

I'm porting an Oracle function to Postgres which has one of the input parameters as refcursor type. The ported Postgres function looks as below.

create or replace function gt_mlt_dtls(dtl_cur IN REFCURSOR, flag TEXT, dt DATE)
returns........

How do I pass the value for dtl_cur parameter as REFCURSOR? In Oracle, CURSOR(some select query) works for inputting a refcursor. Is it possible in PostgreSQL?

1 Answer 1

1

You could DECLARE the cursor in SQL and pass its name to the procedure:

BEGIN;

DECLARE c CURSOR FOR SELECT ...;

CALL gt_mlt_dtls('c', 'text', current_date);

COMMIT;

To call it from another procedure, call

DECLARE
   c refcursor;
BEGIN
   OPEN c FOR SELECT ...;
   CALL gt_mlt_dtls(c, ...);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, how can I call this function(with refcursor input parameter) inside another procedure ?

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.