BEGIN
IF
NEW.id <> OLD.id OR
NEW.customerId <> OLD.customerId OR
THEN BEGIN
INSERT INTO customerDocuments_audit
(
id,customerId,auditActionDate,auditAction)values(NEW.id,NEW.customerId, NOW(),'update'
);
END; END IF;
END$$
If I try to update a column which contains NUll value. A column is getting updated but it is not inserting any value in an audit table.
You need to specifically check for NULL
values as using a NULL
value in a regular logical operation will always return a false
result. Change your IF
statement to this:
IF
NEW.id <> OLD.id OR
NEW.id IS NULL AND OLD.id IS NOT NULL OR
NEW.id IS NOT NULL AND OLD.id IS NULL OR
NEW.customerId <> OLD.customerId OR
NEW.customerId IS NULL AND OLD.customerId IS NOT NULL OR
NEW.customerId IS NOT NULL AND OLD.customerId IS NULL
select a.name into v_newName from Detail a if v_newName is not null Update set a.name = v_newName else Update set a.name = value
end if
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.