0
What is the purpose (common usage) of using triggers and functions in SQL?
3 Respostas
0
1 word: TRIGGERRRRRRRRED!!!
0
You use a trigger when you want to act upon a event which meet a certain condition.
For example a Insert, update or delete query are different types of events and a certain table and/or column can be conditions.
So if someone uses a query that inserts a row into Table1, you could have a trigger act upon that and do something before, after or instead of the query. Note that the trigger reacts to the event being triggered, not the actual data or any changes made.
So for example a update query that updates a column to the exact same value would still trigger the trigger.
When it comes to Functions theres alot of different types of functions with different uses and you would need to read up a bit more on them on other sources since there are to many to list here.
For example some datefunctions can be used inside a query to be used inside a where-clause to filter on todays date or even add/remove a certain amount of days.
You can read more about Triggers and uses here which explains it quite well.
http://www.tutorialspoint.com/plsql/plsql_triggers.htm
- 1
triger uses for before insert or after insert , before update after update, before delete after delete. ex if u have 2 table one is very detailed one is summary u can use trigger here after inserting to main detailed table trigger will be triggered(active) inserts summary of the details table to summary table same as update or delete