From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | "Johnny Jørgensen" <pgsql(at)halfahead(dot)dk> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: PL/pgSQL loops? |
Date: | 2001-11-28 16:24:54 |
Message-ID: | 20011128081825.J32047-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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 Jrgensen" 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';
From | Date | Subject | |
---|---|---|---|
Next Message | wHarouny | 2001-11-28 16:27:37 | email address for questions |
Previous Message | James Orr | 2001-11-28 15:38:41 | Re: View question |