Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Do I need a commit or Not in Trigger...

OnenessboyOct 19 2010 — edited Oct 19 2010
Hi,

Below is my code. This is for audit purpose. For doing a commit after insert, I included Pragma for this trigger.
But on several searches i found that there is no need of commit inside but it automatically commits..
I am bit confused by studying varyiing posts in forums..

Can somebody give me clarity on this and placement of commit in below trigger body is right ?

I am using 10g version.
CREATE OR REPLACE TRIGGER RESERVE_AUDIT
BEFORE UPDATE   ON T_COST
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
   PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	IF UPDATING
                THEN
   		INSERT INTO AUDIT_CONTROL 
                    		(TYPE,
                      		NO_LU_CONTROL, 
                      		CD_FACTOR, 
                 		OLD_AMT, 
                      		WHO_UPDATED,
                       		LAST_UPDATE)
   		VALUES
  	 		('RES',
  	    		:OLD.NO_LU_CONTROL,
               		 	:OLD.CD_FACTOR,
                		 :OLD.CLE_AMOUNT,
                   		 :OLD.ID_USER,
			 SYSDATE)
                END IF;
  COMMIT;	
   END RESERVE_AUDIT;
Thanks in advance
Prasanth
This post has been answered by 796772 on Oct 19 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2010
Added on Oct 19 2010
17 comments
1,654 views