我编写了以下触发器:
CREATE FUNCTION trig_func() RETURNS trigger AS $$
BEGIN
IF NEW = OLD
THEN -- update would do nothing, doing something...
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trig BEFORE UPDATE ON some_table
FOR EACH ROW EXECUTE PROCEDURE trig_func();
这清楚说明了我想要实现的目标,但是代替NEW = OLD
合适的东西是什么?
答案 0 :(得分:2)
is distinct from
运算符可以比较完整的行,并将正确处理null。
所以你想要
if new is not distinct from old then
...
end if;