In the SQL shown below I am joining several tables in order to compare record count totals. How do you cause SQL to generate a exception error and abnormally terminate the procedure when any one of the columns being compared do not match?
===========================================================
select bal.detail_record_cnt, act.trl_policy_record_total, act.trl_agent_record_total
from commdev.comm_agent_balances_trl_stg1 bal, commdev.comm_policy_agent_trl_stg1 act,
commdev.comm_agent_activity_count agtcnt, commdev.comm_policy_activity_count polcnt,
commdev.comm_agent_balance_count balcnt
where bal.detail_record_cnt = balcnt.agent_balance_count
and act.trl_agent_record_total = agtcnt.agent_activity_count
and act.trl_policy_record_total = polcnt.policy_activity_count;
===========================================================
select bal.detail_record_cnt, act.trl_policy_record_total, act.trl_agent_record_total
from commdev.comm_agent_balances_trl_stg1 bal, commdev.comm_policy_agent_trl_stg1 act,
commdev.comm_agent_activity_count agtcnt, commdev.comm_policy_activity_count polcnt,
commdev.comm_agent_balance_count balcnt
where bal.detail_record_cnt = balcnt.agent_balance_count
and act.trl_agent_record_total = agtcnt.agent_activity_count
and act.trl_policy_record_total = polcnt.policy_activity_count;