DROP PROCEDURE TMP_OP_CTRLTURNDETUpdProc
GO
CREATE PROCEDURE TMP_OP_CTRLTURNDETUpdProc
(
	@CORRNBR	INT,
	@SIDE		UD_CARA,
	@HOSENUMBER	TINYINT,
	@STARTREADING	NUMERIC(13,3),
	@ENDREADING	NUMERIC(13,3),
	@QTYSALES	UD_STOCK,
	@QTYSERAF	UD_STOCK,
	@QTYOTHER	UD_STOCK,
	@TOTQTY		UD_STOCK
 
)
AS
BEGIN
    BEGIN TRAN

    UPDATE 	TMP_OP_CTRLTURNDET
    SET		STARTREADING=@STARTREADING,
		ENDREADING=@ENDREADING,
		QTYSALES=@QTYSALES,
		QTYSERAF=@QTYSERAF,
		QTYOTHER=@QTYOTHER,
		TOTQTY=@TOTQTY

    WHERE CORRNBR=@CORRNBR AND SIDE=@SIDE AND HOSENUMBER=@HOSENUMBER

    IF (@@error!=0 AND @@ROWCOUNT=0)
    BEGIN
        RAISERROR  20000 'Error Actualizando en TMP_OP_CTRLTURNDET '
        ROLLBACK TRAN
        RETURN(1)
    
    END

    COMMIT TRAN

END

