DROP PROCEDURE GrabarDetDepositoProc
GO
CREATE PROCEDURE GrabarDetDepositoProc
(	@CORRNBR int,
	@BATNBRDEPOSITSITE  UD_CORRELATIVOS
)
AS
BEGIN    

	DECLARE   @ERROR	integer


       INSERT 	INTO 	OP_DEPOSITSITEDET(SITEID,BATNBRDEPOSITSITE,DATEPROCE,SEQUENCE,CUSTIDSS,DEPOSITPASSWORD,DATEDEPOSIT,CURYID,CURYRATE,TOTALPEN,TOTALUSD,DEBEHABER,STATUS,USERID)
		SELECT 	SITEID,@BATNBRDEPOSITSITE,DATEPROCE,SEQUENCE,CUSTIDSS,DEPOSITPASSWORD,DATEDEPOSIT,CURYID,CURYRATE,TOTALPEN,TOTALUSD,DEBEHABER,STATUS,USERID
		FROM	TMP_OP_DEPOSITSITEDET
		WHERE	CORRNBR=@CORRNBR

	IF (@@error!=0 OR @@ROWCOUNT=0 )
    	BEGIN
        	RETURN(1)
    	END

	INSERT  INTO 	OP_NBRDOCSUMMARY(SITEID,BATNBRDEPOSITSITE,DATEPROCE,SEQUENCE,DOCSUMMARYTYPEID,NBRDOCSUMMARY) 
		SELECT 	SITEID,@BATNBRDEPOSITSITE,DATEPROCE,SEQUENCE,DOCSUMMARYTYPEID,NBRDOCSUMMARY
		FROM 	TMP_OP_NBRDOCSUMMARY
		WHERE 	CORRNBR=@CORRNBR

	IF (@@error!=0 OR @@ROWCOUNT=0 )
    	BEGIN
        	RETURN(1)
    	END

  RETURN (0)

END


