Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have three Table A (selfid as primary key) , Table B, Table C.

If I update a column value in Table A , the trigger should perform an check operation on Table B and Table C.

If selfid exists in tables then it should only update the column value in tables(B,C).

If selfid doesn’t exists in tables then it should perform an insert operation on tables(B,C).
Posted
Comments
ZurdoDev 6-May-15 10:03am    
Do you have a question? I sure hope it isn't, "Will you do this for me?"
virusstorm 6-May-15 10:05am    
I wouldn't do this with a trigger. You will run into a lot of performance issues related to concurrency and locking. I would write a stored procedure to handle this logic.

1 solution

If you've got a list of conditions like this, a trigger is a bad option as they don't scale well. Use a stored procedure instead and have your code call that. The stored procedure can handle all of this and do it without locking the table for any other operation on another request.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900