Team Fly |
EMP_HQ becomes a valid object of the select statement just as if it were a table of its own.
Just as their name implies, triggers are stored objects that fire based on the execution of certain events. Suppose a payroll application wants to audit salary increases. A trigger is created that fires when the salary column in hr_master is updated. The trigger could do the following:
1. Create a record in sal_audit.
2. Trap the time and date of the transaction.
3. Place the user's login ID in the doer column.
4. Place the old salary value in the old_sal column.
5. Place the new salary value in new_sal column.
Code in the trigger traps the event by specifying on update. While triggers are commonly used for auditing, the types of activities they can initiate are endless.
NOTE
Triggers cannot exist independent of an Oracle Database 10g table. They are associated with one and only one table and, if a table is dropped, so is the trigger.
Triggers, as well as procedures, packages, and functions described next, are most commonly written using PL/SQL. The PL/SQL programming language is the topic of Chapter 6.
Procedures perform specific tasks as applications interact with the Oracle Database 10g. If there are a number of interrelated activities to carry out in one place, a procedure is an ideal way to do this. Procedures can accept parameters when invoked and can interact with objects in the Oracle Database 10g. They encapsulate related activities into single programming units that simplify logic and share data values as they perform various activities. They offer extremely flexible features, many of which are not available with triggers.
Functions are very close relatives of procedures, except that they return a value to the code that called them. Oracle Database 10g delivers many functions out of the box and
Team Fly |