In this conclusion to a three-part series, you'll learn how to view existing Oracle triggers, modify them, and use them in your PHP applications. This article is excerpted from chapter 37 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).
Viewing Existing Triggers
Using the Oracle Database XE GUI, it’s easy to view existing triggers. From the Object Browser page, select Triggers. In the scroll box on the left, select the trigger to view. In Figure 37-6, the trigger AU_TECHNICIAN_T1is selected and you can see the details of the trigger itself.
Figure 37-6. Trigger details
Clicking the SQL tab above the trigger details shows you the SQL used to create the trigger:
CREATE OR REPLACE TRIGGER "AU_TECHNICIAN_T1" AFTER update on "TECHNICIAN" for each row WHEN (NEW.AVAILABLE = 0) begin UPDATE TICKET SET TECHNICIAN_ID = 0 WHERE TECHNICIAN_ID = :NEW.TECHNICIAN_ID; end; / ALTER TRIGGER "AU_TECHNICIAN_T1" ENABLE /
Modifying or Deleting a Trigger
There is no functionality for modifying an existing trigger using the Oracle Database XE GUI. Therefore, you must copy the attributes of the existing trigger, drop it using the Drop button shown in Figure 37-6, and recreate it using the steps outlined previously.
If you do not have the Oracle Database XE GUI available, you can drop the trigger using the SQL Commands interface or another SQL command-line interface using theDROP TRIGGERcommand as follows:
DROP TRIGGER AU_TECHNICIAN_T1;
Caution When you drop a table, all triggers defined against the table are also deleted.