DROP FUNCTION IF EXISTS ies.t_insured_policy_delete CASCADE;
CREATE  FUNCTION ies.t_insured_policy_delete()
RETURNS TRIGGER AS $$
BEGIN
		DELETE FROM ies.t_policy_summary WHERE policysummaryid  = old.insuredpolicyid;
    RETURN NEW; 
END;
$$ LANGUAGE plpgsql;


DROP TRIGGER IF EXISTS t_insured_policy_after_delete ON ies.t_insured_policy;
CREATE TRIGGER t_insured_policy_after_delete
AFTER DELETE ON ies.t_insured_policy
FOR EACH ROW EXECUTE FUNCTION ies.t_insured_policy_delete();