Oracle if updating trigger
CREATE or REPLACE TRIGGER emp_after_update AFTER UPDATE OF empid ON emp FOR EACH ROW DECLARE BEGIN update emp_backup set empid = :new.empid where empid = :old.empid; DBMS_OUTPUT.
PUT_LINE('empid successfully updated into emp_backup table'); END; The above trigger named ’emp_after_update’ will be initiated whenever ’empid’ column in ’emp’ table gets updated.
SQL Notice in the last update it indicated that x and y both were being updated (which they were), but the update didn't change the value (both x and y were 1 prior to the update which set them to 1). You can use updating (column) but it will only tell you that the column itself is being updated and not if the value has changed.
If you need to determine if the value is changing, you'll still need to code comparison logic for :old and :new values.
where employee_id = i_employee_id else insert ( ... In this case, the question to ask whether the procedure will mostly be used to update existing employee records, or insert new ones.
ITST_ITEM_TIDE_CODE; insert into gb_transaction(gb_tide, gb_isbn, gb_used_on_hand, gb_new_on_hand) values(:new. V_AD_ON_HAND is a view that pulls an inventory count.
gb_transaction is my new table where I'm logging these events Comparing it to other peoples code it looks like it should run but I'm getting "Warning: Trigger created with compilation errors." Assuming you are using SQL*Plus, when you get a warning that your trigger (or any other PL/SQL block) has compilation errors, you can type "SHOW ERRORS" at the SQL prompt to get a list of the compilation errors. The problem, I believe is with the :new designations for a delete trigger.
CREATE OR REPLACE TRIGGER gb_qty_change AFTER UPDATE OR INSERT OR DELETE ON F_ITEM_STORE FOR EACH ROW DECLARE v_qty V_AD_ON_HAND%rowtype; v_isbn TD_ITEM_DESCRIPTION.
TD_IDENTIFIER%type; BEGIN delete from gb_transaction where gb_tide = :new.