Home » RDBMS Server » Server Administration » trigger trouble
trigger trouble [message #369814] Wed, 18 October 2000 01:07 Go to next message
deepti jain
Messages: 1
Registered: October 2000
Junior Member
I CREATED A TRIGGER AND IT COMPILED SUCCESSFULLY.
BUT,WHEN I TRY TO INSERT NEW VALUES IN THE TABLE ,IT GIVES AN ERROR (ERR.THE TABLE IS MUTATING....!)
Re: trigger trouble [message #369816 is a reply to message #369814] Wed, 18 October 2000 02:44 Go to previous messageGo to next message
Venkatramanan
Messages: 10
Registered: October 2000
Junior Member
Hi Deepti,

Whenever we are using DML statements inside the triggers, we have to be careful of Table Mutation.

In the insert trigger, I think U are trying to query or change the same table. The table will be mutated during the whole execution of the DML operation.

So, u try a different approach for the logic.

Or U try the operations which mutates the table in statement level and the desired action at row level.

Venkatramanan.
Re: trigger trouble [message #369824 is a reply to message #369814] Wed, 18 October 2000 20:46 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
This often occurs when there is a relationship (FK) between the table with the trigger and a table you are targetting in the trigger. Easiest was is to remove the relationship if you can. Usually you don't want to do this though as it's usually there for good reason.

One workaround is as follows, but requires lots of coding. Search on the net for sample code:
1.) Create a PRE condition trigger to identify the changes you want to make. Store these in a PL/SQL table in a package.
2.) Create a POST condition trigger to go and fetch the changes from the PL/SQL table. Now apply these to complete the transaction.

By the way, don't think you can hide your original logic in a procedure and then call the procedure from the trigger - wont work.

Rather than using a trigger, you could make your application to call a procedure.
Previous Topic: Call Oracle Reports from Stored Procedure
Next Topic: PL\SQL: Procedure can't be created through SQL*PLUS 'cause it's too long
Goto Forum:
  


Current Time: Sat Apr 27 09:22:52 CDT 2024