[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

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

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] ECPG - bug in EXEC SQL WHENEVER NOT FOUND?

2004-03-07 Thread Christian Rank
Michael Meskes wrote: > On Sat, Mar 06, 2004 at 09:54:13PM +0100, Christian Rank wrote: > >>Today I ran into problems when combining a C program with SQL statements >>with the ECPG interface of PostgreSQL: >> >>According to the documentation, it should be possible with >> EXEC SQL WHENEVER NOT F