From: | Steve Tucknott <steve(at)retsol(dot)co(dot)uk> |
---|---|
To: | PostGreSQL <pgsql-novice(at)postgresql(dot)org> |
Subject: | Trigger Procedures |
Date: | 2005-05-12 10:56:19 |
Message-ID: | 1115895379.1238.55.camel@retsol1 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Is there a way of passing NEW. fields into a trigger procedure - I know
that they are automatically available - but there is a reason...
We 'build' the trigger procedures when we define the table - typically
we have a common 'trace' procedure that gets fired on update/insert.
This function takes a series of arguments - one of which is a variably
named foreign key.
ie the trace_action could be called as:
CREATE TRIGGER insert_sourcedetprodTrace BEFORE INSERT ON sourcedetprod
FOR EACH ROW
EXECUTE PROCEDURE trace_actions (
'insert',
'sourcedet',
'sourcedetprod',
'Products Added',
NEW.sourcedetRecNo,
NEW.recNo
);
OR it could be called as:
CREATE TRIGGER insert_sourcedetupgrTrace BEFORE INSERT ON sourcedetupgr
FOR EACH ROW
EXECUTE PROCEDURE trace_actions (
'insert',
'sourcedetprod',
'sourcedetupgr',
'Upgrade Items Added',
NEW.sourcedetprodRecNo,
NEW.recNo
);
At the moment, I can't seem to pass the NEW values into trace_actions.
Similarly, as trace_actions is a common process, I have no way of
knowing whether NEW contains 'sourceDetRecNo' or 'sourceDetProdRecNo'
(unless I case the table name)
I know I can get around this by splitting the common trace_actions into
table specific traces, but I'm hoping that there's something that I've
missed and I can use some form of syntax like above.......
--
Regards,
Steve Tucknott
ReTSol Ltd
DDI 01903 828769
MOBILE 07736715772
From | Date | Subject | |
---|---|---|---|
Next Message | Vitaly Belman | 2005-05-12 13:26:37 | Re: Autocommit in Postgresql |
Previous Message | Olivier Thauvin | 2005-05-12 08:14:56 | Re: Autocommit in Postgresql |