IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'[dbo].[sp_fco_del_rep_cajas]') 
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   DROP PROCEDURE dbo.sp_fco_del_rep_cajas
GO
CREATE PROCEDURE dbo.sp_fco_del_rep_cajas
(
  @psi_id_rep  smallint,
  @pvc_usuario varchar(30),
  @pti_cod_rep tinyint
)
/********************************************************************/
/*** Fiscal de Colombia de Data Tecnologia                        ***/
/*** Descripcion: limpia las tablas involucradas en la ejecucion  ***/
/*** del reporte de cajas                                         ***/
/*** Autor:	Diana Cecilia Rios Peinado                            ***/
/*** Fecha:	Mayo 14 de 2005                                      ***/
/********************************************************************/
--OCT-03-05: Pasada a SQL de Oracle
AS
BEGIN
     DELETE fco_reportes_proc
     WHERE id_rep = @psi_id_rep
     AND usuariow = @pvc_usuario
     AND cod_rep = @pti_cod_rep

     DELETE fco_parafiscales_tmp
     WHERE id_rep = @psi_id_rep
     AND usuariow = @pvc_usuario
     
     DELETE fco_parafiscales
     WHERE id_rep = @psi_id_rep
     AND usuariow = @pvc_usuario
     AND cod_rep = @pti_cod_rep

     DELETE fco_reportes_mm
     WHERE id_rep = @psi_id_rep
     AND usuariow = @pvc_usuario
     AND cod_rep = @pti_cod_rep
     
END

GO
GRANT EXECUTE ON sp_fco_del_rep_cajas TO Public
GO