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 5DB5A9DC9F0 for ; Wed, 28 Dec 2005 11:48: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 91175-07 for ; Wed, 28 Dec 2005 11:48:27 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id E390D9DC9C9 for ; Wed, 28 Dec 2005 11:48:20 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jBSFmPFE017344; Wed, 28 Dec 2005 10:48:25 -0500 (EST) To: Don Croata cc: pgsql-sql@postgresql.org Subject: Re: Cursors and recursion In-reply-to: References: Comments: In-reply-to Don Croata message dated "Wed, 28 Dec 2005 11:29:19 -0300" Date: Wed, 28 Dec 2005 10:48:25 -0500 Message-ID: <17343.1135784905@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.05 required=5 tests=[AWL=0.050] X-Spam-Score: 0.05 X-Spam-Level: X-Archive-Number: 200512/220 X-Sequence-Number: 23762 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