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 ?