Обсуждение: Stored procedures returning cursors

Поиск
Список
Период
Сортировка

Stored procedures returning cursors

От
Rodolfo Stangherlin
Дата:
I was trying to call a procedure returning a "ref cursor" in a
PostgreSQL database. It works with psycopg2 2.3.2, but not with 2.4.4.

My code looks like this:
http://osdir.com/ml/python.db.psycopg.devel/2005-10/msg00116.html

The result is a "cursor <unnamed portal 1> doesn't exists"
How I can do it in the right way?


Thanks!


--
Rodolfo

---------------------------------------
Essa mensagem foi enviada pelo UCS Mail



Re: Stored procedures returning cursors

От
Daniele Varrazzo
Дата:
On Tue, Dec 20, 2011 at 6:47 PM, Rodolfo Stangherlin <RStanghe@ucs.br> wrote:
> I was trying to call a procedure returning a "ref cursor" in a PostgreSQL
> database. It works with psycopg2 2.3.2, but not with 2.4.4.
>
> My code looks like this:
> http://osdir.com/ml/python.db.psycopg.devel/2005-10/msg00116.html
>
> The result is a "cursor <unnamed portal 1> doesn't exists"
> How I can do it in the right way?

You should give a name to the portal to make it work.

The example still works (I had to omit the quotes decorating the name
in Portal.__init__) but there is an easier technique to obtain the
same result: execute the function creating the (named) ref cursor,
then just create a named cursor to steal it. It has been discussed
recently in this list and there is an example in the documentation:
see <http://initd.org/psycopg/docs/usage.html#server-side-cursors> (in
the note box).

-- Daniele