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



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to