am Tue, dem 10.06.2008, um 18:45:51 -0700 mailte Medi Montaseri folgendes:
> Hi, > > I need to increament a counter such as myTable.Counter of type integer > everytime myTable.status a boolean column is updated. Can you help me complete > this... > > create trigger counter_trigger after update on myTable.counter > execute procedure 'BEGIN statement; statement; statement END'
much simpler, use a RULE instead a TRIGGER like my example:
Suppose, i have a table called foo, it contains now:
test=# select * from foo; i --- 1 2 (2 rows)
I create a sequence and a RULE:
test=*# create sequence foo_counter; CREATE SEQUENCE test=*# create or replace rule foo_update as on update to foo do also select nextval('foo_counter'); CREATE RULE
And now i do a update on foo:
test=*# update foo set i=2; nextval --------- 1 (1 row)
test=*# update foo set i=3; nextval --------- 2 (1 row)