On update we create an Audit of the field values that have changed by comparing the new value to the old one, this works fine unless either value is NULL, at which point it regards the null value as the same as the field value, is there a better way of getting round this problem than running a couple or OR statemensts?
Ideal: (But does not pick up NULLs)
IF :OLD.Field1 <> :NEW.Field1 THEN
CreateAuditRecord(oldVal,NewVal)
END IF;
Work Around: (Is there a better way of doing this?)
IF OLD.Field1 <> :NEW.Field1)
OR
(NEW.Field1 is null) and Old.Field1 is not null))
OR
(NEW.Field1 is not null) and Old.Field1 is null))
THEN
CreateAuditRecord(oldVal,NewVal)
END IF;
Thanks for any advice
Ideal: (But does not pick up NULLs)
IF :OLD.Field1 <> :NEW.Field1 THEN
CreateAuditRecord(oldVal,NewVal)
END IF;
Work Around: (Is there a better way of doing this?)
IF OLD.Field1 <> :NEW.Field1)
OR
(NEW.Field1 is null) and Old.Field1 is not null))
OR
(NEW.Field1 is not null) and Old.Field1 is null))
THEN
CreateAuditRecord(oldVal,NewVal)
END IF;
Thanks for any advice