Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1


Ratings: (0)|Views: 357|Likes:
Published by sanjay.gupta8194

More info:

Published by: sanjay.gupta8194 on Aug 24, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





TRIGGERSWhat is trigger?
A Trigger is a PL/SQL Block or PL/SQL procedure associated with a table, view, schema, or thedatabase.A Trigger executes Implicitly whenever a particular event takes place.A trigger can either be:
Application Trigger
: Fires implicitly whenever an event Occurs with a particular application.
Database Triggering
:Fires implicitly whenever a data event (such as DML) or system event (such aslogon or shut down) occurs on a Schema or database.
 -Database tables can be defined on tables and on views.-The excessive use of triggers can result in complex interdependencies which may be difficult tomaintain in large applications.-If the logic of trigger is very lengthy, create the stored procedure with logic and invoke them in thetrigger body.-Database triggers fire for every user each time the events occurs on which the trigger is created.
When should we design Triggers?We design Triggers to :
-perform related action.-Centralize global operations
When should we not design Triggers?We don't design Triggers to :
Where functionality is already built into the Oracle Server.-That Duplicate others triggers
What are the parts of a database trigger?
The parts of a trigger are:-A triggering event or statement-A trigger restriction-A trigger action
What are the various types of database triggers?
There are 12 types of triggers, they are combination of:Insert, Delete and Update Triggers.Before and After Triggers.Row and Statement Triggers.(3*2*2=12)
What is the advantage of a stored procedure over a database trigger?
We have control over the firing of a stored procedure but we have no control over the firing of a trigger.What is the maximum no of statements that can be specified in a trigger statement?One.
Can views be specified in a trigger statement?
What are the values of :new and :old in Insert/Delete/Update Triggers ?
INSERT : new = new value, old = NULLDELETE : new = NULL, old = old valueUPDATE : new = new value, old = old value
What are cascading triggers? What is the maximum no of cascading triggers at a time?
When a statement in a trigger body causes another trigger to be fired, the triggers are said to becascading. Max = 32.
What are mutating triggers?
A trigger giving a SELECT on the table on which the trigger is written.
What are constraining triggers?
A trigger giving an Insert/Update on a table having referential integrity constraint on the triggeringtable.
Can database trigger written on synonym of a table and if it can be then what would be the effectif original table is accessed.
Yes, database trigger would fire.
Is the After report trigger fired if the report execution fails?
Can U disable database trigger? How?
Yes. With respect to tableALTER TABLE TABLE_NAMEDISABLE all_trigger 
Can you use a commit statement within a database trigger.
What is INSTEAD OF Trigger?
We use INSTEAD OF Triggers to modify data in which the DML statement has been issued against annon- updatable view. These Triggers are called INSTEAD OF Triggers, because unlike other triggers, the oracleserver fires the trigger Instead of executing the triggering statement. The Trigger is used to perform Insert,Update, Delete statement against a view, and the Instead of Trigger works invisibly in the background to makethe right action take place.
Why do we INSTEAD OF Trigger?
A view can not be modified by normal DML statements if the view query contains set of operators, groupfunctions, clauses such as GROUP BY, CONNECT BY, START, The DISTINCT OPERATOR or Joins. For example if the view contains more than one table, an insert to the view may entail an insertion into one table andan update to another. So, we write an INSTEAD OF Trigger that fires when we write an insert against the view.Instead of the original insertion, the trigger body executes, which results in an insertion of data into one table andan update to another table.
-If the view is inherently updatable and has INSTEAD OF TRIGGERs, the triggers take precedence. INSTEADOF Triggers are row triggers.-The CHECK OPTION for views is not enforced when insertions or updates to the views are performed by usingINSTEAD OF triggers. The INSTEAD OF trigger body must ensure the check.- If the INSTEAD OF triggers can only be row trigger, if it is omitted, the trigger is still defined as a row trigger.
TRIGGERING Event that can cause trigger to fire:-
A data definition statement on an object in the database or schema.
A specific user (or any user) logging on or off.
A database shut down or start up.
A specific or any error that occurs.DDL trigger fires only if the object being created is a cluster, index, package, procedure, role, sequence,synonyms, table, tablespace, trigger, type, view or user.
Causes the oracle server to fire the trigger whenever a server error message islogged.
Causes the oracle server to fire the trigger whenever a user logs onto the database.
Causes the oracle server to fire the trigger whenever a user logs Off the database.
Causes the oracle server to fire the trigger whenever the database is opened.
Causes the oracle server to fire the trigger whenever the database is shutdown.
What is the use of CALL statement?
A call statement enables you to call a stored procedure, rather than calling the PL/SQL body in the trigger itself.The procedure can be implemented in PL/SQL, JAVA, C.There is no semicolon at the end of the CALL statement.
What is Mutating table?
A Mutating table is a table that is currently being modified by an UPDATE, DELETE or INSERT statement, or atable that might need to be updated by the effects of a declarative DELETE CASCADE referential integrityaction. A table is not considered mutating for STATEMENT triggers.The triggered table itself is a mutating table, as well as table referencing it with the FOREIGN KEY constraint.This restriction prevents a row trigger from seeing an inconsistent set of data.

Activity (15)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
kmdasari liked this
rajeshtechm liked this
Ong Gaik Sun liked this
prof_kt liked this
garyboy liked this
raja826 liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->