alt
Advertisement
Sponsored links
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow Oracle 9i arrow Tutorial 14: Oracle 9i : Database Triggers
Site Search


Tutorial 14: Oracle 9i : Database Triggers
Article Index
Tutorial 14: Oracle 9i : Database Triggers
Page 2

 

Handling multiple situations

A trigger can be used to handle multiple situations as shown in the following example. By using conditional predicates UPDATING, INSERTING, or DELETING we can handle each situation.


CORRELATION NAMES

While using row triggers, the trigger action statement can access column values of the row that is being processed currently. This is done using correlation names. There exist two correlation names for every column of the table, one for the column old value and the other for its new value. We use qualifier NEW with column name for new values and qualifier OLD is used to refer old value of the column.

Example:

IF :new.sal < :old.sal THEN
……

The REFERENCING option is used to avoid name conflicts between correlation names and table names. For example if you are using a table by name new or old with field names say SNO, NAME (though it is a very rare situation) then the ambiguity arises. To avoid this we use REFERENCING option.

Mutating Table: is a table that is presently under modification by INSERT, UPDATE, or DELETE statement, or a table that has referential integrity constraint with DELETE CASCADE OPTION.

Constraining Table: is a table, which is to be read by triggering statement either directly or indirectly.

In the above example when we tried to delete a row using SQL statement (Mutating Table) , which fires AFTER DELETE trigger. The body of this trigger is having a select statement that tries to read the table. This operation is not allowed by oracle. Hence we received a runtime error and total action is rolled back by Oracle. (The row is not deleted)

Download Sample Code 1

Download Sample Code 2

Download Sample Code 3


Trackback(0)
Comments (15)add comment

juturik said:

  Yes.

This is very good site to beginers.

Thanx a lot
July 08, 2005

maran said:

  It is really good place for a beginner to learn. This article would be very fruitful, if you could give a strategy to avoid the mutating issue.

Thanks for a wonderful basics.
August 24, 2005

Skhan said:

  Hi,
Its a good place to begin with triggers. It provides solid funda. Please add the advanced info on triggers.
Thanks!
Sami
May 16, 2007

shivam said:

  Nice, short and excellent description of triggers. Good for beginners. Writtern in easy and lucid language and good illustrations too.
May 17, 2007

shivam said:

  Nice description and good illustrations. Excellent for beginners.
May 17, 2007

bhanucs said:

  I find it very useful for beginners. THX
June 14, 2007

koumi said:

  hi dis is the good way of learning course
June 28, 2007

arulkumar said:

  hi trigger concepts r very good also easy and simple
August 03, 2007

Murali_Vadoni said:

  It is really helpfull in refreshing the topic

Thanks
September 10, 2007

AJAY K said:

  This Document is rally good.
September 17, 2007

KayKay said:

  I was looking for some 1 minute intro to Triggers.....and I got it here the way I wanted.
December 02, 2007

tharanath said:

  hi. this document is really good and excellent for beginners.....
April 29, 2008

Prasad.Gandra said:

  Excellent Information for starters... Really easy to Understand
May 16, 2008

mohan12 said:

  very nice,
but need to add more examples..
May 28, 2008

Lokesh Devanga said:

  These is very Nice,
but i need some more Examples.
June 17, 2008

Write comment

busy

 
< Prev   Next >
Exforsys Offers
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape