From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: "Johnny Jørgensen" <pgsql@halfahead.dk>
Cc: pgsql-sql@postgresql.org
Subject: Re: PL/pgSQL loops?
Date: Wed, 28 Nov 2001 08:24:54 -0800 (PST)
Message-ID: <20011128081825.J32047-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <200111281540250450.0093EFC2@mail.halfahead.dk>
I'm not really sure of what's going on, and am uncertain
if this is a transcription error or not. In addition
table schema would be helpful for us to try the function. :)
In my machine with test tables I get,
NOTICE: Error occurred while executing PL/pgSQL function cleanup_order
NOTICE: line 13 at for over select rows
ERROR: Attribute 'cur_order_id' not found
I assume this is because of the use of cur_order_id rather than
cur_order.id in the inner loop definition.
On Wed, 28 Nov 2001, [ISO-8859-1] "Johnny Jørgensen" wrote:
> I have a problem with the following function:
>
> CREATE FUNCTION cleanup_order(integer,integer)
> RETURNS boolean
> AS '
> DECLARE
> p_id ALIAS FOR $1;
> o_id ALIAS FOR $2;
> cur_order record;
> cur_item record;
> BEGIN
> << order_loop >>
> FOR cur_order IN SELECT * FROM ordre WHERE person_id = p_id AND status = 1 AND id != o_id
> LOOP
> RAISE NOTICE ''outer: %'',cur_order.id;
>
> << item_loop >>
> FOR cur_item IN SELECT * FROM item WHERE order_id = cur_order_id
> LOOP
> RAISE NOTICE ''inner: %'',cur_item.id;
>
> UPDATE item SET ordre_id = o_id WHERE id = cur_item.id;
>
> END LOOP;
>
> UPDATE ordre SET status = 0 WHERE id = cur_order.id;
>
> END LOOP;
> RETURN TRUE;
> END;
> '
> LANGUAGE 'plpgsql';
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: sszabo@megazone23.bigpanda.com, pgsql@halfahead.dk
Subject: Re: PL/pgSQL loops?
In-Reply-To: <20011128081825.J32047-100000@megazone23.bigpanda.com>
* 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