From: | Bob Jones <r(dot)a(dot)n(dot)d(dot)o(dot)m(dot)d(dot)e(dot)v(dot)4+postgres(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | cursor "x" does not exist |
Date: | 2018-04-14 14:44:17 |
Message-ID: | CA+HuS5F_anOtn+jJjF1VPuWX_pkOiN_FC2vPDDgkJhFs-s8CZQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
My apologies if I'm being incredibly stupid here, but I've reviewed
what the docs have to say about naming portals and I still can't see
where I'm going wrong here ?
CREATE FUNCTION blah(v_id text,v_cursor refcursor) RETURNS refcursor
AS
$BODY$
BEGIN
OPEN v_cursor FOR SELECT * FROM blah where idcol=v_id;
RETURN v_cursor;
END;
$BODY$
LANGUAGE plpgsql;
The select query in here does return data, so I know the output from
below is certainly expected to return something.
BEGIN;
SELECT blah('A','B');
blah
--------------------------
B
(1 row)
FETCH ALL IN B;
ERROR: cursor "b" does not exist
P.S. As a side-question, if anyone here has experience in using
Postgres as a backend to PHP, are refcursors the way to go or should I
be thinking of SETOF or other return styles ?
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-04-14 15:38:53 | Re: cursor "x" does not exist |
Previous Message | David Steele | 2018-04-13 20:54:47 | Re: Barman versus pgBackRest |