Re: PL/SQL: To determine which field was update
From: Chris Hamilton <Christopher.H.Hamilton_at_usace.army.mil>
Date: 1997/08/07
Message-ID: <33E9CAB4.3B04_at_usace.army.mil>#1/1
Chris Hamilton - Oracle Database Admin.
AVANCO Intl. / US Army Corps of Engineers Christopher.H.Hamilton_at_usace.army.mil http://www.serve.com/cowpb/chamilton.html Received on Thu Aug 07 1997 - 00:00:00 CEST
Date: 1997/08/07
Message-ID: <33E9CAB4.3B04_at_usace.army.mil>#1/1
Benson Butt wrote:
>
> You can do a comparison using :old and :new.
> i.e.
> if :old.fld1 != :new.fld2
> -- do something since the field is updated
> endif
You may wish to use the nvl() function to make sure nulls are compared properly (since null doesn't equal anything, but it doesn't not equal anything either).
For instance,
For varchar2:
if nvl(:old.field1,' ') != nvl(:new.field2,' ') then
blah-blah;
end if;
For numeric:
if nvl(:old.field1,0) != nvl(:new.field2,0) then
blah-blah;
end if;
For date:
if nvl(:old.field1,'01-jan-01') != nvl(:new.field2,'01-jan-01') then
blah-blah;
end if;
Chris
Chris Hamilton - Oracle Database Admin.
AVANCO Intl. / US Army Corps of Engineers Christopher.H.Hamilton_at_usace.army.mil http://www.serve.com/cowpb/chamilton.html Received on Thu Aug 07 1997 - 00:00:00 CEST