DROP PROCEDURE IN_INTRAITEMUpdProc
GO
CREATE PROCEDURE IN_INTRAITEMUpdProc
(
    @SITEID            UD_IDSITE,
    @BATNBR            char(10),
    @TYPEDOCID         UD_TYPEMOVEID,
    @SEQUENCE          smallint,
    @INVTIDSKU         UD_IDCORPORATIVO,
    @INVTIDBARR        UD_CODIGOBARRA,
    @QTY               UD_STOCK,
    @TAXIGV            numeric(4, 2)               = NULL,
    @STDCOSTPEN        UD_COSTO                    = NULL,
    @STDCOSTUSD        UD_COSTO                    = NULL,
    @STKFISI           bit,
    @INTRDATE          smalldatetime,
    @INTRDATEPROCE     smalldatetime,
    @RLSED             bit,
    @USER1             UD_USER1                    = NULL,
    @USER2             UD_USER2                    = NULL,
    @USER3             UD_USER3                    = NULL,
    @USER4             UD_USER5                    = NULL,
    @USER5             UD_USER5                    = NULL,
    @USER6             UD_USER6                    = NULL,
    @USER7             UD_USER7                    = NULL,
    @USER8             UD_USER8                    = NULL,
    @USER9             UD_USER9                    = NULL,
    @TSTAMP            timestamp)
AS
BEGIN
    BEGIN TRAN

    UPDATE IN_INTRAITEM
       SET INVTIDSKU          = @INVTIDSKU,
           INVTIDBARR         = @INVTIDBARR,
           QTY                = @QTY,
           TAXIGV             = @TAXIGV,
           STDCOSTPEN         = @STDCOSTPEN,
           STDCOSTUSD         = @STDCOSTUSD,
           STKFISI            = @STKFISI,
           INTRDATE           = @INTRDATE,
           INTRDATEPROCE      = @INTRDATEPROCE,
           RLSED              = @RLSED,
           USER1              = @USER1,
           USER2              = @USER2,
           USER3              = @USER3,
           USER4              = @USER4,
           USER5              = @USER5,
           USER6              = @USER6,
           USER7              = @USER7,
           USER8              = @USER8,
           USER9              = @USER9
     WHERE SITEID    = @SITEID
       AND BATNBR    = @BATNBR
       AND TYPEDOCID = @TYPEDOCID
       AND SEQUENCE  = @SEQUENCE

    IF (@@error!=0)
    BEGIN
        RAISERROR  20001 'IN_INTRAITEMUpdProc: Cannot update  in IN_INTRAITEM '
        ROLLBACK TRAN
        RETURN(1)
    
    END

    COMMIT TRAN

    RETURN(0)
END