Re: ecpg: using a cursor returned by a stored function - Mailing list pgsql-interfaces

From Gaetano Sferra
Subject Re: ecpg: using a cursor returned by a stored function
Date
Msg-id I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it
Whole thread Raw
List 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




pgsql-interfaces by date:

Previous
From: "Gaetano Sferra"
Date:
Subject: Re: ECPG: using cursor returned from a stored function
Next
From: Doug Homoelle
Date:
Subject: newbie libpq question...