Oracle trigger if updating then

CREATE or REPLACE TRIGGER emp_after_insert AFTER INSERT ON emp FOR EACH ROW DECLARE BEGIN insert into emp_backup values (:new.empid, :new.fname, :new.lname); DBMS_OUTPUT.

PUT_LINE('Record successfully inserted into emp_backup table'); END; Second Problem: We want o update a record in the ’emp_backup’ table if a corresponding record is updated in the ’emp’ table.

In Oracle, a sequence object (created by CREATE SEQUENCE statement) is used to generate IDs (auto-increment, identity values).

oracle trigger if updating then-56oracle trigger if updating then-38

CREATE OR REPLACE TRIGGER check_salary_count AFTER UPDATE OR INSERT OF grade ON salgrade DECLARE v__grade_changes NUMBER v_sal_changes NUMBER; BEGIN SELECT upd, max_upd INTO v_grade_changes, v_max_changes FROM audit_table WHERE user_name = user AND tablename = SALGRADE AND column_name = GRADE IF v_salary_changes Hi Monique, I tested out some of your triggers in Oracle ( i.e.As we’ve already created both the tables in above example, we will directly write a trigger for ‘AFTER UPDATE’.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.This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. By joining today you can post your own programming questions, respond to other developers questions, and eliminate the ads that are displayed to guests. Hi I am currently using Oracle 9i, using the Scott database and have a number of contraints which I need to implement.I have very little knowledge of creating triggers, but have had a go.9i Release 1 ) hence some of the demo tables/columns were not present. I am jotting down some of the triggers that I developed: ************************************************** ******************** Q1) No new orders are to be accepted from customers in the city of BURLINGAME.


Leave a Reply