X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 1C53B9DC9F5 for ; Wed, 28 Dec 2005 15:37:23 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29709-02-2 for ; Wed, 28 Dec 2005 15:37:22 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.201]) by postgresql.org (Postfix) with ESMTP id 724BC9DC8A4 for ; Wed, 28 Dec 2005 15:37:20 -0400 (AST) Received: by zproxy.gmail.com with SMTP id 14so1599838nzn for ; Wed, 28 Dec 2005 11:37:21 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=WSImaplQ9y3IejIa4CcQOi0scOZ3byyATtl1bwfV/1v2SOvGrmUatnndMYt5ETAKRJ8SynTPh0Xq2VM0piUWsiW0IADhRO6SRfnJaiioqviL6Hh1T5ep9d0scwSmrAOUd++QFZ7B5Ktrn8gi8IYQAYUpO8CQetfjLaj3WbpoCr0= Received: by 10.36.50.8 with SMTP id x8mr5651230nzx; Wed, 28 Dec 2005 11:37:21 -0800 (PST) Received: by 10.37.13.6 with HTTP; Wed, 28 Dec 2005 11:37:21 -0800 (PST) Message-ID: Date: Wed, 28 Dec 2005 16:37:21 -0300 From: Don Croata To: pgsql-sql@postgresql.org Subject: Re: Cursors and recursion In-Reply-To: <17343.1135784905@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2677_11807910.1135798641204" References: <17343.1135784905@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.120, HTML_MESSAGE=0.001] X-Spam-Score: 0.121 X-Spam-Level: X-Archive-Number: 200512/223 X-Sequence-Number: 23765 ------=_Part_2677_11807910.1135798641204 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Please, if someone recalls a link, book, piece of code or anything with inf= o about this technique for PL/PgSQL (8.1), please let us know. We've been searching into google, groups.google, http://archives.postgresql.org and http://www.postgresql.org/docs/8.1/interactive with no results. Most of the answers are related to unclosed cursors for the "ERROR: cursor ... already in use" message. Here's the sample code for this issue (i.e. error because cursor already defined in recursive PL/PgSQL function) at: http://www.croata.cl/cur.sql -- Thanx again, Cro On 12/28/05, Tom Lane wrote: > > Don Croata writes: > > It's a function who has a cursor and calls itself, but the problem > raises > > after the first recursion, when PgSQL complains: > > > ERROR: cursor "cur" already in use > > > Are the cursors kept globally? or cached like TEMP TABLE? > > Cursor names are global within a particular session. > > IIRC there is a syntax for opening a cursor without specifying a name, > in which case plpgsql will pick one that's not in use. This is probably > what you want to use. > > regards, tom lane > ------=_Part_2677_11807910.1135798641204 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Please, if someone recalls a link, book, piece of code or anything wit= h info about this technique for PL/PgSQL (8.1), please let us know. We've b= een searching into google, groups.google, http://archives.postgresql.org and http://www.postgresql.org/docs/8.1/interactive<= /a> with no results. Most of the answers are related to unclosed curso= rs for the "ERROR: cursor ... already in use" message.
 
 
--
 
Thanx again,
Cro
 
On 12/28/05, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Don Croata <el.croata@gmail.com> writes:
> It's a fu= nction who has a cursor and calls itself, but the problem raises
> after the first recursion, when PgSQL complains:

> ERROR= :  cursor "cur" already in use

> Are the curs= ors kept globally? or cached like TEMP TABLE?

Cursor names are globa= l within a particular session.

IIRC there is a syntax for opening a cursor without specifying a na= me,
in which case plpgsql will pick one that's not in use.  Th= is is probably
what you want to use.

    &nbs= p;            &= nbsp;     regards, tom lane

------=_Part_2677_11807910.1135798641204--