IF OBJECT_ID('dbo.sp_fco_del_pi_pens_proc') IS NOT NULL
    DROP PROCEDURE dbo.sp_fco_del_pi_pens_proc 
GO
CREATE PROCEDURE dbo.sp_fco_del_pi_pens_proc
(
    @pch_compania char(4),
    @psi_anio smallint,
    @pti_mes tinyint,
    @pch_sucursal char(10)
)
AS
/*************************************************************************/
-- Modulo Fiscal Colombiano 2.0 ADAM V3
-- Descripcion: Baja de Procesos de Planilla Integrada Pensionados
-- Autor: Juan Carlos Leguizamon
-- Fecha: Julio 2005
-- Revisiones:
/*************************************************************************/
BEGIN
    IF NOT EXISTS(SELECT 1 FROM fco_pi_pens_proc
              WHERE compania = @pch_compania AND anio = @psi_anio
                AND mes = @pti_mes AND sucursal = ISNULL(@pch_sucursal, ''))
    BEGIN
        RAISERROR ('El registro a eliminar no existe', 16, 1)
        RETURN
    END

    DELETE fco_pi_pens_proc
    WHERE compania = @pch_compania
      AND anio = @psi_anio
      AND mes = @pti_mes
      AND sucursal = ISNULL(@pch_sucursal, '')
END
GO
GRANT EXECUTE ON dbo.sp_fco_del_pi_pens_proc TO PUBLIC
GO
