Re: Help for an Oracle Newbie

From: Shakespeare <whatsin_at_xs4all.nl>
Date: Sat, 23 Aug 2008 21:11:38 +0200
Message-ID: <48b060ee$0$183$e4fe514c@news.xs4all.nl>

"DA Morgan" <damorgan_at_psoug.org> schreef in bericht news:1219425349.943220_at_bubbleator.drizzle.com...
> Shakespeare wrote:
>
>>> CREATE OR REPLACE TRIGGER bu_t
>>> BEFORE UPDATE
>>> ON t
>>> FOR EACH ROW
>>> BEGIN
>>> IF (:NEW.lastmodified IS NULL) OR (:NEW.lastmodified =
>>> :OLD.lastmodified) THEN
>> ^
>> Hey, you didn't suggest this line!
>
> Did I need to? <g>

To ask is to know...

>
>>
>> And
>>> IF (:NEW.lastmodified IS NULL)
>>
>> a) is never true because of the default value so a useless condition
>> (except for avoiding comparing null with null maybe)
>
> That's why it is there but you are correct that it could probably be
> dropped.
>
> and
>> b) is incorrect, because lastmodified should be updated when not null
>> too.
>
> If it is NOT NULL then it will not be equal to the previous value.

O yes it can be, if a user selects a record and updates some columns except lastupdated. (E.g. using Oracle Forms: query a record, update and commit.) In that case lastmodified will not be updated, where the record was changed!

> --
> Daniel A. Morgan
> Oracle Ace Director & Instructor
> University of Washington
> damorgan_at_x.washington.edu (replace x with u to respond)
> Puget Sound Oracle Users Group
> www.psoug.org

Shakespeare
(to quote Vladimir M. Zakharychev quoting Voltaire "Better is the enemy of good.") Received on Sat Aug 23 2008 - 14:11:38 CDT

Original text of this message