Skip site navigation (1) Skip section navigation (2)

Re: ecpg: using a cursor returned by a stored function

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$ (view raw or whole thread)
Lists: pgsql-interfaces
I've found a solution, may be it isn't "chic" and may be it is a ECPG bug but it
Follow this example:

-- This is the stored function
CREATE FUNCTION myfunc(refcursor) RETURNS refcursor AS'
ref ALIAS FOR $1;
OPEN ref FOR SELECT * FROM mytable;

-- 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 

pgsql-interfaces by date

Next:From: jing hanDate: 2004-11-10 22:09:47
Subject: about libpq-C FETCH ALL performance issue
Previous:From: Gaetano SferraDate: 2004-11-10 08:49:31
Subject: Re: ECPG: using cursor returned from a stored function

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group