I’m having problems running my application – Oracle is raising an
ORA-04092: cannot COMMIT in a trigger issue.
Now I am trying to find the trigger which contains commit statement. Is it possible to find the trigger which has the commit statement in all `dba_triggers’?
select * from dba_triggers statement
gives me all dba triggers. Now I have to search these triggers with the word commit.
If you get the full error stack, you should be able to see what line of what trigger is throwing the error. That’s the most efficient approach. For example, if you create a trigger that commits and run an INSERT, the stack trace will show you what line of what trigger caused the error.
You can search the source for all triggers looking for a particular string. Something like this will look for the literal “COMMIT” in any trigger in whatever schemas you specify.
On the other hand, there is a strong probability that the trigger that is failing is calling a stored procedure and it is the stored procedure that is committing. So searching the source of your triggers may not be beneficial.
You could potentially mitigate that by doing a recursive query on
DBA_DEPENDENCIES(orALL_DEPENDENCIESorUSER_DEPENDENCIESdepending on your privilege level and the scope of what you want to search for) to find all of the procedures that are potentially called from any trigger and to search the source of all of those procedures fromDBA_SOURCE. But that’s going to be much more complex than simply examining the full error stack.