--------------------------------------------------------- [T_POLICY] обьеденил все триггеры в один

DROP FUNCTION IF EXISTS ies.t_policy_insert_update CASCADE;
CREATE  FUNCTION ies.t_policy_insert_update()
RETURNS TRIGGER AS $$
BEGIN
	
	IF (TG_OP = 'INSERT') THEN
	
   	 	new.createdate = now();

	END IF;

		new.xtimestamp = now();

    RETURN NEW;
END;
$$ LANGUAGE plpgsql;


DROP TRIGGER IF EXISTS t_policy_before_insert_update ON ies.t_policy;
CREATE TRIGGER t_policy_before_insert_update
BEFORE INSERT OR UPDATE ON ies.t_policy
FOR EACH ROW EXECUTE FUNCTION ies.t_policy_insert_update();