Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL: To determine which field was update
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
![]() |
![]() |