----------------------[T_INSURED] объединил 2 триггера в 1 (INSURED_after_insert,INSURED_after_update)
DROP FUNCTION IF EXISTS ies.t_insured_insert_update CASCADE;
CREATE  FUNCTION ies.t_insured_insert_update()
RETURNS TRIGGER AS $$
BEGIN
	
	IF (TG_OP = 'INSERT') THEN
   	 	new.createdatetime = now();
	END IF;

		new.editdate = now();
		new.FIO = replace(new.LastName || CHR(160) || new.FirstName || coalesce(CHR(160) || new.Patronymic, CHR(160)),'ё','е');

    RETURN NEW;
END;
$$ LANGUAGE plpgsql;


DROP TRIGGER IF EXISTS t_insured_before_insert_update ON ies.t_insured;
CREATE TRIGGER t_insured_before_insert_update
BEFORE INSERT OR UPDATE ON ies.t_insured
FOR EACH ROW EXECUTE FUNCTION ies.t_insured_insert_update();