Re: Stored procedures returning cursors - Mailing list psycopg

From Daniele Varrazzo
Subject Re: Stored procedures returning cursors
Date
Msg-id CA+mi_8YgDWTieGYJ2LmNLNkEZD4MsoO5gUHyKmmREhuFhDrfAg@mail.gmail.com
Whole thread Raw
In response to Stored procedures returning cursors  (Rodolfo Stangherlin <RStanghe@ucs.br>)
List psycopg
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

psycopg by date:

Previous
From: Rodolfo Stangherlin
Date:
Subject: Stored procedures returning cursors
Next
From: Christopher David Howie
Date:
Subject: Rows from a stored procedure result are stringified