cursor "x" does not exist - Mailing list pgsql-general

From Bob Jones
Subject cursor "x" does not exist
Date
Msg-id CA+HuS5F_anOtn+jJjF1VPuWX_pkOiN_FC2vPDDgkJhFs-s8CZQ@mail.gmail.com
Whole thread Raw
Responses Re: cursor "x" does not exist
Re: cursor "x" does not exist
List 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 ?


pgsql-general by date:

Previous
From: David Steele
Date:
Subject: Re: Barman versus pgBackRest
Next
From: Tom Lane
Date:
Subject: Re: cursor "x" does not exist