For any insert into TableB, if its event_id matches the event_id in TableA
check the event_class in TableA
if it happens to be 'Company'
then insert the event_id, attr_name and a flag 'C' into TableC
else if it happens to be 'Address'
then insert the event_id, attr_name and a flag 'A' into TableD.
Then compare the event_id from TableB and TableC.
If they match, update Cname of TableC with attr_value of TableB.
Then compare the event_id from TableB and TableD.
If they match, update Dname of TableC with attr_value of TableD.
Any pointers on how to write this would be greatly appreciated.
Comment: Is there an excellent reason forcoding this in a trigger? Complex business logic like this is generally best left to whatever procedure is doing the inserting.
Bookmarks