Can we create trigger on SELECT statement? If we can create, how?

Showing Answers 1 - 11 of 11 Answers

Archana Patil

  • Dec 20th, 2005
 

No we cannot create trigger on select statement, we can create trigger only on insert / update / delete

Also check Syntax for trigger

Create or replace trigger <trigger_name>

before/after  insert/update/delete

This shows only after insert, update or delete trigger will get fire not on select statement.

  Was this answer useful?  Yes

chandrika

  • Feb 6th, 2006
 

by using triggers we cannot trigger.by using attributes like %found 0r %rowcount we can trigger a select statement

  Was this answer useful?  Yes

Divesh

  • Apr 23rd, 2006
 

Triggers are always created on DML statements i.e Insert/update/delete only .. not on the select statement

  Was this answer useful?  Yes

Anand

  • Apr 27th, 2006
 

Hello,

No its Possible to have a DDL commands in a Trigger but this has been included from Oracle 8i version, prior to this you can only have DML Commands placed inside the Trigger Block.

As far as Select is concerned there is no good reason to prohibit the user or put constraints while viewing the data, and if so the views are used for very well that purpose only.

  Was this answer useful?  Yes

kiranxl

  • Jun 19th, 2007
 

Yes, we can create trigger like functionality on select statement like, which user has select which table and most importantly what sql query issued by using dbms_fga built in package. just check it out.

  Was this answer useful?  Yes

jiten

  • Aug 27th, 2007
 

Hello

Someone has given answer that use dbms_fga
but it's not a write answer becoz it's used for keeping the track
which user has applied select operation on table.

It's one king of policy that is used for security purpose.

We can create trigger for DDL and DML statements.

  Was this answer useful?  Yes

chowdary

  • Sep 6th, 2007
 

We can create trigger on DML, DDL transaction but it is not possible to create on Select statement one point we can create triggers on database system events like logon, shutdown also

Thanq friends

  Was this answer useful?  Yes

Andrew

  • Sep 7th, 2007
 

May be it is better to trace a select statment with on logon trigger.
like:

CREATE OR REPLACE TRIGGER SYS.ON_LOGON_ALL

AFTER LOGON ON DATABASE

WHEN (

USER = 'MAX'

)

BEGIN

EXECUTE IMMEDIATE 'ALTER SESSION SET SQL_TRACE=TRUE';

--EXECUTE IMMEDIATE 'alter session set events ''10046 trace name context forever, level 12''';

EXCEPTION

WHEN OTHERS THEN

NULL;

END;

/

  Was this answer useful?  Yes

Divisha

  • Dec 30th, 2019
 

Can You please elaborate in what way can we do it ?

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions