How to pass NEW/OLD to procedures called from trigger functions in PostgreSQL? -
let's suppose have trigger function, code complex handy split more procedures. want operate new (or old update/delete triggers) variable in of them. there alternative sending function parameter every procedure called original trigger function?
if need pass them around, i'm quite sure can appropriately typed records (e.g. newrow tablename%rowtype).
http://www.postgresql.org/docs/current/static/plpgsql-declarations.html
that said, unless run giant queries results use throughout trigger function, breaking trigger smaller parts cleaner calling subfunctions imho. note can conditionally execute triggers, e.g.:
create trigger "01_do_stuff_upd" on update after tablename each row when (old.field <> new.field , ...) execute procedure do_stuff_upd_part_01(); the thing have in mind when doing above, in postgres (and contrary sql spec), triggers executed in alphabetical order rather in order they're created.
Comments
Post a Comment