Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Oracle Tips #4 [Trigger : Mutating Tables & Autonomos Transactions]

Digital Innovation Partner

Oracle Tips #4 [Trigger : Mutating Tables & Autonomos Transactions]

Oracle Version : 10g

As you know inside a Oracle row trigger you cannot access to the base table, for example when you make a trigger like this, on a table named “activity“.

when you try to use the table making an update happen this :

toaderror

To avoid this error and obviusly assuming the risk about ricorsive trigger, you can define a custom transaction for your trigger, so you can access to data inside the mutating table. To do this you need to declare “PRAGMA AUTONOMOUS_TRANSACTION;” means that the trigger give a specific transaction. So now you need to specify an explicit “commit;” at the end of the trigger.

The example will result like:

that’s all until next tip
bye
ivan

Tags: , , , , , , , ,

Lascia un commento