create or replace procedure sp_fco_deltot(pch_compania in char,
                                               psi_anio     in number,
                                               pti_mes      in number,
                                               pch_sucursal in char,
                                               pch_tipo_planilla in char) is
begin
  begin
    DELETE fco_integrada_rt03
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt04
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt05
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt06
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt07
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt08
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt09
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt10
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
    DELETE fco_integrada_rt11
     WHERE compania = pch_compania
       AND anio = psi_anio
       AND mes = pti_mes
       AND (sucursal = pch_sucursal OR sucursal = ' ')
       AND tipo_planilla = pch_tipo_planilla;
  exception
    when NO_DATA_FOUND then
      null;
    when others then
      Raise_application_error(-20001,
                              'Error al borrar registros anteriores');
      return;
  end;
end sp_fco_deltot;
/
