Pl sql trigger inserting deleting updating

They are fired because an INSERT is possible and an UPDATE is possible. It seems to me that the confusion around merge may arise from thinking about merge as an equivelant for the "update else insert" (aka.

[email protected] merge into t 2 using (select * from dual where 1=0) 3 on (t.x = dummy) 4 when matched then update set y = 5 5 when not matched then insert values (1,1); before insert before update after update after insert 0 rows merged. Though meager is my wisdom when compared to that of Tom, even a blind squirl finds an acorn now and then, so please allow me to offer my explanation of merge vs. upsert) sequence of logic we are all familiar with.

Indeed this is discussed at length all over the internet.

That for each row it is considering, merge is effectively doing two dml operations, yet only one of them will actually affect a row.

The merge fired the same triggers that the upsert logic sequence fired.

If the merge only executed the insert triggers because in the end it only did an insert, then it wouldn't be duplicating the upsert concept.

; select * from employee01; -------- ---------- ----------- ------------------- -------- ------- | emp_id | emp_name | city | designation | salary | perks | -------- ---------- ----------- ------------------- -------- ------- | 1 | david | delhi | manager | 12000 | 855 | | 2 | shaha | mumbai | assistant manager | 13000 | 853 | | 3 | sha | puna | scales manager | 11000 | 850 | | 4 | jack | bangalore | designer | 14000 | 854 | | 5 | james | mangalore | web designer | 15000 | 1124 | -------- ---------- ----------- ------------------- -------- ------- 5 rows in set (0.00 sec) sql select * from employee01; -------- ---------- ----------- ------------------- -------- ------- | emp_id | emp_name | city | designation | salary | perks | -------- ---------- ----------- ------------------- -------- ------- | 1 | david | delhi | manager | 11600 | 855 | | 2 | shaha | mumbai | assistant manager | 12600 | 853 | | 3 | sha | pune | scales manager | 10600 | 850 | | 4 | jack | bangalore | designer | 13600 | 854 | | 5 | james | mangalore | web designer | 14600 | 1124 | | 6 | mike | chennai | developer | 15100 | 840 | -------- ---------- ----------- ------------------- -------- ------- 6 rows in set (0.00 sec) In the above example, before insert trigger will fire the condition before inserting a record inside the table or on the table, and update operation is performed on the column salary(Set Salary=Salary-400 where perks select * from employee01; -------- ---------- ----------- ------------------- -------- ------- | emp_id | emp_name | city | designation | salary | perks | -------- ---------- ----------- ------------------- -------- ------- | 1 | david | delhi | manager | 12000 | 855 | | 2 | shaha | mumbai | assistant manager | 13000 | 853 | | 3 | sha | puna | scales manager | 11000 | 850 | | 4 | jack | bangalore | designer | 14000 | 854 | | 5 | james | mangalore | web designer | 15000 | 1124 | | 6 | mike | chennai | develpoer | 15500 | 840 | -------- ---------- ----------- ------------------- -------- ------- 6 rows in set (0.00 sec) sql CREATE TRIGGER updtrigger BEFORE UPDATE ON Employee01 FOR EACH ROW BEGIN IF NEW. i.e., after creating the student_update table it will fire on the student_log2 table and all the values will be displayed on the student_log2 table which was inserted in student_table02.

Dear All, When i am compliing trigger with only "after update", trigger is running fast.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “pl sql trigger inserting deleting updating”