pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gaetano Sferra <gaesferr@libero.it>
To: pgsql-interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: ecpg: using a cursor returned by a stored function
Date: Wed, 10 Nov 2004 15:22:43 +0100
Message-ID: <I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it> (raw)

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 





Message-ID: <I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it>
Permalink:  ../I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it/
Also on:    postgresql.org/message-id/I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: gaesferr@libero.it
  Subject: Re: ecpg: using a cursor returned by a stored function
  In-Reply-To: <I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox