Medi Montaseri wrote:
> 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'
>
> Q1- how do I narrow the event to "update on a column not a row"
Use a row-level trigger and test to see if the column of interest has
been altered. Eg:
IF new.fieldname IS DISTINCT FROM old.fieldname THEN -- Do the work
END IF;
> Q2- can I just provide an inline procedure for the execute
No, at present you must create a function that returns TRIGGER and then
use that as the target to execute. At least as far as I know.
--
Craig Ringer