X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7261B53B6B for ; Wed, 30 Mar 2005 08:29:10 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72592-09 for ; Wed, 30 Mar 2005 07:29:08 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0517F53B5E for ; Wed, 30 Mar 2005 08:29:07 +0100 (BST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2U7T2FP001826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Mar 2005 00:29:05 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2U7T234017714; Wed, 30 Mar 2005 00:29:02 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2U7T0qQ017713; Wed, 30 Mar 2005 00:29:00 -0700 (MST) (envelope-from mfuhr) Date: Wed, 30 Mar 2005 00:29:00 -0700 From: Michael Fuhr To: dsyoon@metasoftworks.com Cc: pgsql-sql@postgresql.org Subject: Re: when using a bound cursor, error found... Message-ID: <20050330072900.GA17635@winnie.fuhr.org> References: <008b01c53455$6992a590$2d216b3d@notebook04> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <008b01c53455$6992a590$2d216b3d@notebook04> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/383 X-Sequence-Number: 20862 On Tue, Mar 29, 2005 at 08:49:49PM +0900, ?????? wrote: > I 'll use a bound cursor with parameters. > But when I use such a cursor, I found a error. > I don't know error message. It's usually a good idea to post the error message. In most cases it should say what's wrong, or at least where something's wrong. > DECLARE > p_param1 VARCHAR; > p_param1 VARCHAR; You've declared the same variable twice; the second declaration should be p_param2. > OPEN cur_test(p_param2); > > for rec_test in cur_test loop I don't think you can iterate over a cursor this way. Rather than use an explicit cursor, why not use "FOR rec_test IN SELECT ..."? FOR loops automatically use cursors so you don't have to open one yourself. But if you want to use a cursor then you could do something like this: OPEN cur_test(p_param2); LOOP FETCH cur_test INTO rec_test; EXIT WHEN NOT FOUND; -- rest of code END LOOP; CLOSE cur_test; -- Michael Fuhr http://www.fuhr.org/~mfuhr/