DROP PROC EliminarListaCliente
GO
CREATE PROC EliminarListaCliente
(  @PRCLVLCUSTID	 UD_PRCLVLCUSTID 

)
AS
BEGIN
	BEGIN TRAN
		
		DELETE 
		FROM 	OP_PRCLVLCUSTDET
		WHERE 	PRCLVLCUSTID=@PRCLVLCUSTID

		IF (@@ERROR!=0 OR @@ROWCOUNT=0)
    			BEGIN
       				RAISERROR  20000 'Error Eliminando en OP_PRCLVLCUSTDET'	
       				ROLLBACK TRAN
       				RETURN(1)               
    			END 


		--ELIMINO LA CABECERA   		

		DELETE 
		FROM 	OP_PRCLVLCUST
		WHERE 	PRCLVLCUSTID=@PRCLVLCUSTID

		IF (@@ERROR!=0 OR @@ROWCOUNT=0)
    			BEGIN
       				RAISERROR  20000 'Error Eliminando en OP_PRCLVLCUST'	
       				ROLLBACK TRAN
       				RETURN(1)               
    			END 


	COMMIT TRAN
   RETURN(0)
END 