We can't give TCL statement (commit,rollback) in oracle trigger..
So what is the solution???
Write a procedure with commit and PRAGMA AUTONOMOUS_TRANSACTION and call this procedure inside the trigger as mention below.
Write procedure as follow..
create or replace
Procedure Test
As
PRAGMA AUTONOMOUS_TRANSACTION;
Begin
Insert Into Emp_Test Values (600,'Rama2',1000,'chennai');
commit;
END;
Procedure Test
As
PRAGMA AUTONOMOUS_TRANSACTION;
Begin
Insert Into Emp_Test Values (600,'Rama2',1000,'chennai');
commit;
END;
And fire a trigger as follows
create or replace
TRIGGER TRG_TEST
After Insert On Emp
FOR EACH ROW
Declare
Begin
test();
End;
TRIGGER TRG_TEST
After Insert On Emp
FOR EACH ROW
Declare
Begin
test();
End;
So in this way, you can write a TCL (commit,rollback) inside a trigger
Comments
Post a Comment