I'm trying to create a trigger that prevents a column to be updated as follows:
If column value is "A", it cannot be updated to "B", and if column value is "B", it cannot be updated to "A".
CREATE OR REPLACE FUNCTION cancelled_order() RETURNS trigger LANGUAGE plpgsql AS $function$BEGIN IF OLD.status = 'Cancelled' THEN NEW.status != 'Accomplished'; END IF; IF OLD.status = 'Accomplished' THEN NEW.status != 'Cancelled'; END IF; RETURN NEW; END; $function$; CREATE TRIGGER No_cancelled_acomplished BEFORE UPDATE OF status ON clinical.tb_orders EXECUTE PROCEDURE cancelled_order();
The error that comes out is:
Sintaxis error: !=
Any idea, why?