Triggers
You use constraints to automatically enforce data integrity rules whenever a user
tries to write or modify a row in a table. There are times when youwant to use the
same kind of timing for your own application-specific logic. Oracle includes triggers
to give you this capability.
Although you can write triggers to perform the work of a constraint,
Oracle has optimized the operation of constraints, so it??™s best to
always use a constraint instead of a trigger if possible.
A trigger is a block of code that is fired whenever a particular type of database event
occurs to a table. There are three types of events that can cause a trigger to fire:
??? A database UPDATE
??? A database INSERT
??? A database DELETE
You can, for instance, define a trigger to write a customized audit record whenever a
user changes a row.
Triggers are defined at the row level. Youcan specify that a trigger be fired for each
row or for the SQL statement that fires the trigger event. As with the previous discussion
of constraints, a single SQL statement can affect many rows, so the specification
of the trigger can have a significant effect on the operation of the trigger and the performance
of the database.
Pages:
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252