Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Simple Trigger Question
I have a "Before", "Row Level" trigger set up on a table and for some
reason I cannot get one of the updates to fire properly in the
trigger.
The trigger handles several updates to the "NEW" fields, but for some reason I have one that is giving me problems.
This portion that I'm having a problem with updates a "Date" field (of type "Date") based on value in another field of type VarChar(2) 255.
The portion of the trigger is as follows:
:NEW.UpdateDate := CASE WHEN (:NEW.ImageUrl <> :Old.ImageUrl)
THEN SYSDATE
WHEN (:NEW.ImageURL IS NULL)
THEN NULL
ELSE :NEW.UpdateDate END;
When the ImageUrl value is set (ie: "Http:") it should set the
"UpdateDate" field to the current Date/Time based on the SysDate
function. When the ImageURL value is changed to some other non NULL
value, the "UpdateDate" value should get updated with SysDate. If the
ImageURL value is set to NULL the "UpdateDate" value should also get
set to Null. If the record changes but the "ImageURL" value remains
the same no update to the "UpdateDate" field should take place.
The problem is that the first time I set the "ImageUrl" field to some
Non-Null values, the "UpdateDate" field is not updating. A 2nd change
to the "ImageURl" field to a Non-Null value does cause the
"UpdateDate" value to update as it should.
What do I need to do to the statment above, to make trigger update the
"UpdateDate" field upon the initial change of the "ImageUrl" field?
Any help would be appreciated.
Thank You
Lee Received on Tue Jul 27 2004 - 14:48:48 CDT