Skip to Main Content
  • Questions
  • How do I find out if a particular trigger is executing or is being internally ignored from execution inn Oracle 11gR2?

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, A Reader.

Asked: October 16, 2015 - 5:49 pm UTC

Last updated: September 27, 2018 - 2:30 am UTC

Version: 11.2.0.4

Viewed 10K+ times! This question is

You Asked

Hi Tom,

I am a frequent reader of AskTom. Your in-depth and precose answers are always great.

I would like to know if there is any SQL (based on Data Dictionary, v$ or x$ views) that I can use to find out id a particular db trigger is executing or being ignored by Oracle from execution? The DB I am using is 11.2.0.4.

Thanks very much in advance.

Regards.

and Connor said...

I'm not entirely sure what you mean by "ignored". A trigger will fire if it is enabled, and not fire if it is not. You can check the status from any of the xxx_TRIGGERS views.

For a currently running trigger, you can do some data mining of the V$ views, for example:

SQL> create table T ( x int );

Table created.

SQL> create or replace trigger TRG
  2  before insert on T
  3  for each row
  4  declare
  5    p int;
  6  begin
  7    select :new.x into p from dual;
  8    dbms_lock.sleep(30);
  9  end;
 10  /

Trigger created.

SQL>
SQL> insert into T values (10);

[will take 30 seconds to run]



From another session, I can run:

SQL> select owner, object_name
  2  from   dba_objects
  3  where  object_id =
  4    ( select PLSQL_ENTRY_OBJECT_ID
  5      from   v$session
  6      where  sid = 256 );   -- 256, the sid for session 1

OWNER                          OBJECT_NAME
------------------------------ -----------------
SCOTT                          TRG


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Trigger last execution time

Lancerique, September 26, 2018 - 4:12 pm UTC

Hey Connor,

From Golden gate 12.x , triggers on replicated site are disabled. So before enable-ling a specific trigger in replicat, I would like to see if triggers are getting executed for the replicated data or not. So are there any v$views which can let me know when was trigger executed last time?
Connor McDonald
September 27, 2018 - 2:30 am UTC

To do so, I would (temporarily if needed) enable AUDIT on INSERT, UPDATE, DELETE on the table for which the table is defined.

(The choice of INSERT, UPDATE, DELETE depends on what statements you have your triggers defined for).

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library