Site Meter Technology How Tos: How to use commit in a Trigger

Tuesday, November 4, 2008

How to use commit in a Trigger

Say you have a procedure which inserts/updates records.

And you want to do this after a row is updated in a table in oracle.

Now you create a trigger and call this procedure. But it fails because Oracle throws an error saying "Commit - not allowed in a trigger".

The solution for this is to use the following :

create or replace myprocedure is

pragma AUTONOMOUS_TRANSACTION;

begin

...

do stuff

...

end;

And that should take care of it.

Technorati Tags: , , ,

No comments: