create or replace procedure sp_fco_del_pi_pens_proc(pch_compania in char,
                                                    psi_anio     in integer,
                                                    pti_mes      in integer,
                                                    pch_sucursal in char) is
  v_dummy integer;
begin
  begin
    select 1
      into v_dummy
      from fco_pi_pens_proc
     where compania = pch_compania
       and anio = psi_anio
       and mes = pti_mes
       and sucursal = nvl(pch_sucursal, ' ');
  exception
    when no_data_found then
      Raise_application_error(-20000, 'El registro a eliminar no existe.');
  end;

  delete fco_pi_pens_proc
   where compania = pch_compania
     and anio = psi_anio
     and mes = pti_mes
     and sucursal = nvl(pch_sucursal, ' ');

end sp_fco_del_pi_pens_proc;
/
