From: | "Gaetano Sferra" <gaesferr(at)libero(dot)it> |
---|---|
To: | "pgsql-interfaces" <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: ecpg: using a cursor returned by a stored function |
Date: | 2004-11-10 14:22:43 |
Message-ID: | I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hello,
I've found a solution, may be it isn't "chic" and may be it is a ECPG bug but it
work.
Follow this example:
-- This is the stored function
CREATE FUNCTION myfunc(refcursor) RETURNS refcursor AS'
DECLARE
ref ALIAS FOR $1;
BEGIN
OPEN ref FOR SELECT * FROM mytable;
RETURN ref;
END;
-- This is a piece of ECPG that call the stored function above
EXEC SQL SELECT myfunc('mycursor');
while (sqlca.sqlcode != 100)
{
EXEC SQL FETCH mycursor INTO ... ... ;
... ... ...
}
EXEC SQL CLOSE mycursor;
compiling the above piece of code the ECPG compiler will output:
filename.pgc:xx: ERROR: trying to acces an undeclared cursor mycursor
but it will produce a complete filename.c output anyway and compiling it with cc
or gcc you
will the SELECT output.
It isn't nice but work :)
If you have any other ideas please post it to me, thank you.
Gaetano Sferra
____________________________________________________________
Libero ADSL: navighi gratis a 1.2 Mega, senza canone e costi di attivazione.
Abbonati subito su http://www.libero.it
From | Date | Subject | |
---|---|---|---|
Next Message | jing han | 2004-11-10 22:09:47 | about libpq-C FETCH ALL performance issue |
Previous Message | Gaetano Sferra | 2004-11-10 08:49:31 | Re: ECPG: using cursor returned from a stored function |