Re: [GENERAL] recursive trigger

2004-03-07 Thread Mage
Tom Lane wrote: You should just do if new.parent <> old.parent then new.name = ''old''; As you have it, the inner UPDATE pre-empts the outer because it is applied first. When control comes back from the trigger, the row the trigger was handed is now dead (already updated) and can't be update

Re: [GENERAL] recursive trigger

2004-03-07 Thread Tom Lane
Mage <[EMAIL PROTECTED]> writes: > what's wrong with this? > if new.parent <> old.parent then >update test set name = ''old'' where parent = old.parent; You should just do if new.parent <> old.parent then new.name = ''old''; As you have it, the inner UPDATE pre-empts the outer because

[GENERAL] recursive trigger

2004-03-07 Thread Mage
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, o