From: Michael Fuhr <mike@fuhr.org>
To: dsyoon@metasoftworks.com
Cc: pgsql-sql@postgresql.org
Subject: Re: when using a bound cursor, error found...
Date: Wed, 30 Mar 2005 00:29:00 -0700
Message-ID: <20050330072900.GA17635@winnie.fuhr.org> (raw)
In-Reply-To: <008b01c53455$6992a590$2d216b3d@notebook04>
References: <008b01c53455$6992a590$2d216b3d@notebook04>
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, dsyoon@metasoftworks.com
Subject: Re: when using a bound cursor, error found...
In-Reply-To: <20050330072900.GA17635@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox