Triggers
От | Mitch Vincent |
---|---|
Тема | Triggers |
Дата | |
Msg-id | 00cc01bf56c5$03cd5e80$40ee2fd8@venux.net обсуждение исходный текст |
Ответ на | Re: [SQL] NULL (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: [SQL] Triggers
|
Список | pgsql-sql |
I'm using this funtion via a trigger to total up amounts in several fields (and adding that value into a total field).. CREATE FUNCTION invoice_total_trigger() RETURNS OPAQUE AS ' BEGIN NEW.total := NEW.fee_membership + NEW.fee_logins + NEW.fee_convention + NEW.fee_prints+ NEW.fee_hotlines + NEW.fee_postage + NEW.fee_ups + NEW.fee_late + NEW.fee_other1 + NEW.fee_other2 + NEW.fee_other3 + NEW.fee_pastdue; RETURN NEW; END; ' LANGUAGE 'plpgsql'; That's the function, here is the trigger. CREATE TRIGGER invoice_total_trigger AFTER INSERT OR UPDATE ON invoice FOR EACH ROW EXECUTE PROCEDURE invoice_total_trigger(); It works for updating but not when you insert a new row. Am I doing it wrong? I need the invoice_total_trigger to run every time a row is updated or inserted.. Thanks guys! -Mitch
В списке pgsql-sql по дате отправления: