Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie to triggers

Re: Newbie to triggers

From: Ken Denny <ken_at_kendenny.com>
Date: Thu, 25 Apr 2002 00:11:22 GMT
Message-ID: <Xns91FACE2B5320Akendenny@65.82.44.7>


"Lucas" <Lucas_44_at_hotmail.com> wrote in
news:WDFx8.12147$n%4.807368_at_news2.telusplanet.net:

> Can somebody give me a simple example on how to get a value (ex:
> foreign key) from a 'new record' on a 'after insert' trigger? I know
> all about the mutating error, just don't know how to get around it....

To get the value of a column from a record that is being inserted in an "after insert" trigger use :new.column_name

The mutating error occurs when you try to read the table you're updating. To get around it, use a row-level trigger to save the values you need in a memory array, then use a statement-level trigger to do the reading.

> Also, how do you use the :new and :old that I frequently see? When i
> try it, I get 'bad bind variable'

You should be able to use :new.column_name and :old.column_name without getting any error. You must have been trying to use :new and :old without the column name. If you're doing an insert then :old.column_name will always be null.

-- 
Ken Denny
http://www.kendenny.com/

Always remember you're unique... Just like everyone else. 
Received on Wed Apr 24 2002 - 19:11:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US