Thursday, December 23, 2010

sql trigger inserting row into two tables

Programmer Question

I was looking for a way to create a trigger that would insert the same row into two tables with the same values.



For example, a new row is inserted into pushNotificationQueue as soon as that is inserted, I would like that same exact row to be inserted into messages.



I tried this



CREATE TRIGGER add_to_messages
after insert on mbb_pushNotificationQueue
FOR EACH ROW
insert into mbb_messages select * from mbb_pushNotificationQueue


the only problem with that is that it goes through and adds entries that have already been previously added.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails