CREATE OR REPLACE FUNCTION food600.sk_sez_odecteno()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
BEGIN
IF NEW.odecteno=0 THEN
	UPDATE food600.sk_sez SET odecteno='' WHERE uzaverka=NEW.uzaverka AND id_kas=NEW.id_kas AND id_man=NEW.id_man;
ELSE
	UPDATE food600.sk_sez SET odecteno='ano' WHERE uzaverka=NEW.uzaverka AND id_kas=NEW.id_kas AND id_man=NEW.id_man;
END IF;
RETURN NEW;
END
$BODY$;
