Trigger if updating then

Rated 3.90/5 based on 829 customer reviews

Then we will update values of TXN_NUMBER column of bank_transactions table and will observe values of bank_transactions and bank_transactions_audit tables. You will notice, in audit table, the old values are inserted. CREATE TABLE bank_transactions ( TXN_ID number(10) primary key, TXN_NUMBER varchar2(20), PARTY_NAME varchar2(50), TXN_DATE date, CREATED_BY varchar2(20), CREATED_DATE date ); --Creating bank_transactions_audit table. Avoid to use primary or unique constraint on audit table to avoid any constraint violation in insertion of the same row multiple times in case of multiple updates of transaction table.Then we will create “trg_before_update_txn_audit” Trigger on table bank_transactions.In this example we have introduced two restriction on before UPDATE trigger statement.

trigger if updating then-44

trigger if updating then-47

This statement specifies that Oracle will fire this trigger BEFORE the UPDATE operation is executed.That information, along with your comments, will be governed by DISQUS’ privacy policy.By commenting, you are accepting the DISQUS terms of service. CREATED_DATE); END; --Inserting values INSERT INTO BANK_TRANSACTIONS values ('1','TXN1234','Peter Thomas','12-MAY-2017','HR',sysdate); INSERT INTO BANK_TRANSACTIONS values ('2','TXN9999','Jemes Patel','10-JUN-2016','HR',sysdate); select * from BANK_TRANSACTIONS; --updating values.Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Leave a Reply