DROP PROC AGREGAR_TMP_OP_DEPOSITDET_PROC
GO
CREATE PROCEDURE AGREGAR_TMP_OP_DEPOSITDET_PROC
(
	@CORRNBR	INT,	
    @BATNBRDEPOSIT     UD_CORREL_DEPOSIT,
    @SITEID            UD_IDSITE,
    @SEQUENCE          UD_REGISTRO,
    @CARDID            char(2)                      = NULL,
    @TOTAL             UD_MONTO,
    @CUSTIDSS          UD_CODCLIENT                 = NULL,
    @CURYID            UD_CURYID,
    @deposittypeid     char(1),
    @USER1             UD_USER1                     = NULL,
    @USER2             UD_USER2                     = NULL,
    @USER3             UD_USER6                     = NULL,
    @USER4             UD_USER7                     = NULL)
AS
BEGIN
IF (LEN(LTRIM(RTRIM(@CUSTIDSS)))=0 ) SET   @CUSTIDSS= NULL
IF (LEN(LTRIM(RTRIM(@CARDID)))=0 ) SET   @CARDID= NULL
    BEGIN TRAN

    INSERT INTO TMP_OP_DEPOSITDET(CORRNBR,
				BATNBRDEPOSIT,
                              SITEID,
                              SEQUENCE,
                              CARDID,
                              TOTAL,
                              CUSTIDSS,
                              CURYID,
			      deposittypeid,
                              USER1,
                              USER2,
                              USER3,
                              USER4 
                              )
    VALUES(@CORRNBR,
	@BATNBRDEPOSIT,
           @SITEID,
           @SEQUENCE,
           @CARDID,
           @TOTAL,
           @CUSTIDSS,
           @CURYID,
	@deposittypeid,
           @USER1,
           @USER2,
           @USER3,
           @USER4 
           )

    IF (@@error!=0)
    BEGIN
        RAISERROR  20000 'sp_InsProcOP_DEPOSITDET: Cannot insert because primary key value not found in OP_DEPOSITDET '
        ROLLBACK TRAN
        RETURN(1)
    
    END

    COMMIT TRAN

END


GO
