I have a code that check for few conditions in inserting data
v_region_count number; v_region_count1 number;Begin select count(*) into v_region_count from dss.freight_estimates where weight_maximum = :freight_estimates.weight_maximum AND reg_id_from = :freight_estimates.reg_id_from and reg_id_to = :freight_estimates.reg_id_to and carrmeth_id = :freight_estimates.carrmeth_id and profs_id_cmethtype is null; select count(*) into v_region_count1 from dss.freight_estimates where weight_maximum = :freight_estimates.weight_maximum AND reg_id_from = :freight_estimates.reg_id_from and reg_id_to = :freight_estimates.reg_id_to and carrmeth_id is null and profs_id_cmethtype = :freight_estimates.profs_id_cmethtype;End;
If v_region_count > 0 then msg_alert('The combination of Maximum Weight,Region From, Region To and Carrier Method already exists','E',true);ElsIf v_region_count1 > 0 then msg_alert('The combination of Maximum Weight,Region From, Region To and Carrier Type already exists','E',true);End if;