From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | recursive trigger |
Date: | 2004-03-07 13:37:35 |
Message-ID: | 404B259F.9010900@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
what's wrong with this?
---
create table test (id int, name text, parent int);
insert into test values (1,'a',1);
insert into test values (2,'b',1);
insert into test values (3,'c',1);
create or replace function test() returns trigger as '
begin
raise info ''id: %, oldname: %'',old.id, old.name;
if new.parent <> old.parent then
update test set name = ''old'' where parent = old.parent;
end if;
return new;
end;
' language plpgsql;
create trigger test_trigger before update on test for each row execute
procedure test();
update test set parent = 2;
---
INFO: id: 1, oldname: old
INFO: id: 1, oldname: old
CONTEXT: PL/pgSQL function "test" line 4 at SQL statement
INFO: id: 2, oldname: old
CONTEXT: PL/pgSQL function "test" line 4 at SQL statement
INFO: id: 3, oldname: old
CONTEXT: PL/pgSQL function "test" line 4 at SQL statement
UPDATE 0
-----
PgSQL 7.4.1
Mage
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Meskes | 2004-03-07 14:31:14 | Re: ECPG - bug in EXEC SQL WHENEVER NOT FOUND? |
Previous Message | Tom Lane | 2004-03-07 05:59:04 | Re: 7.4.1 upgrade issues |