0

Any idea why this doesn't display data, and how to fix that?

create or replace function test_refcursor(a refcursor) 
returns setof refcursor as
$$
begin
    open a for select from accounts;
    return next a;
end;
$$ language plpgsql;
begin;

Then to try to select data:

mydb=> begin;
mydb=> select test_refcursor('a');
 test_refcursor
----------------
 a
(1 row)
mydb=> fetch all from a;
--
(58 rows)

Last part doesn't display anything. Does it just not support dynamically type cursors like this?

1 Answer 1

1

Last part doesn't display anything as you don't want anything. Try:

...
open a for select * from accounts;
...
Sign up to request clarification or add additional context in comments.

1 Comment

Oh dear... it's getting late. Thank you, but I'm going to try to delete the question, as it's all based on a typo.

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.