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: Trigger Question - update a last_modified field

Re: Trigger Question - update a last_modified field

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Thu, 18 Oct 2001 20:34:53 +0200
Message-ID: <tsu90sr9smlu82@corp.supernews.com>


Oracle Application Developers manual.

:new is the after image of the column, :old the before image

availability:

             :new            :old
insert     Y                N
update   Y                Y
delete     N?(IIRC)    Y


Using :new and :old is limited to triggers *only*

Hth,

Sybrand Bakker
Senior Oracle DBA
"John Harris" <John.Harris_at_nurs.utah.edu> wrote in message news:MPG.1638bcc58d1be0f0989682_at_news.cc.utah.edu...
> Thanks, worked beautifully. One more question:
> I've tried to find information on the useage of the host variables :new
> and :old. Although I have some vague understanding, what exactly do they
> mean, when do you use them (i.e., :new.last_modified - how does the :new
> relate to the row you're updating, and how does :old come into the
> picture).
> Are their any others? Where can I find documentation on these?
>
> Thanks.
>
>
> In article <0Wwz7.60$%Z5.84_at_pollux.casema.net>,
> r.nospam.lascae_at_wanadoo.nl says...
> > The first method may work, I didn't try it. The idea is correct: you
don't
> > update the table being modified in the trigger itself, rather you assign
a
> > value to the last_modified value in a before update trigger.
> >
> > The following works:
> >
> > CREATE OR REPLACE TRIGGER trigername
> > before UPDATE
> > on table_name
> > for each row
> > declare currtime date;
> > begin
> > currtime := SYSDATE;
> > :new.last_modified := currtime;
> > end;
> > /
> >
> > HTH,
> > Radu
> > "John Harris" <John.Harris_at_nurs.utah.edu> wrote in message
> > news:MPG.16383529b4a6fc74989680_at_news.cc.utah.edu...
> > > I would like to create a row-level trigger for a table which occurs
each
> > > time the a row is updated. For instance, if any column changes then
the
> > > last_modified field gets updated with sysdate.
> > >
> > > Can I use something like (I know this isn't correct, but I haven't
much
> > > experience with this):
> > >
> > > begin
> > > select sysdate into :new.last_modified from dual;
> > > end;
> > > or maybe something like
> > > begin
> > > update table set table.last_modified=sysdate;
> > > end;
> > >
> > > Any help would be greatly appreciated.
> > >
> > > John Harris
> >
> >
> >
Received on Thu Oct 18 2001 - 13:34:53 CDT

Original text of this message

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