create or replace procedure adam.sp_fco_del_procesos_pi(pch_compania in char,
                                                        psi_anio     in number,
                                                        pti_mes      in number,
                                                        pch_sucursal in char,
                                                        pch_tipo_planilla in char) is
  dummy number(1) := 0;
begin
  begin
    select 1
      into dummy
      from fco_procesos_pi
     where compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND nvl(trim(sucursal), ' ') = nvl(pch_sucursal, ' ')
       AND tipo_planilla = pch_tipo_planilla;
  exception
    when no_data_found then
      Raise_application_error(-20001, 'El registro a eliminar no existe');
      return;
  end;

  delete fco_procesos_pi
   where compania = pch_compania
     and anio = psi_anio
     and mes = pti_mes
     and nvl(trim(sucursal), ' ') = nvl(pch_sucursal, ' ')
     and tipo_planilla = pch_tipo_planilla;
end sp_fco_del_procesos_pi;
/
