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

Поиск
Список
Период
Сортировка
От Gaetano Sferra
Тема Re: ecpg: using a cursor returned by a stored function
Дата
Msg-id I6YVXV$CE640DCE042E1D8D3D2F5B3582511133@libero.it
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: "Gaetano Sferra"
Дата:
Сообщение: Re: ECPG: using cursor returned from a stored function
Следующее
От: Doug Homoelle
Дата:
Сообщение: newbie libpq question...