Home > database >  After the EXECUTE transaction count indicates the number does not match the BEGIN and COMMIT stateme
After the EXECUTE transaction count indicates the number does not match the BEGIN and COMMIT stateme

Time:12-03

 USE [TDG. Normal] 
GO
/* * * * * * Object: StoredProcedure [dbo] [sp_SaveForCurrentStockSNBarcode] Script Date: 2020/12/02 13:07:50 * * * * * */
The SET ANSI_NULLS ON
GO
The SET QUOTED_IDENTIFIER ON
GO


The ALTER PROCEDURE [dbo] [sp_SaveForCurrentStockSNBarcode]
@ cVouchType VARCHAR (50),
@ RDID INT
AS
The BEGIN

DECLARE @ AUTOID BIGINT, @ BRDFLAG INT.
DECLARE @ CWHCODE VARCHAR (50), @ CINVCODE VARCHAR (50), @ CBATCH VARCHAR (50), @ CPOSITION VARCHAR (50), @ CBARCODE VARCHAR (50), @ CMADANBARCODE VARCHAR (50);
DECLARE @ CFREE1 VARCHAR (50), @ CFREE2 VARCHAR (50), @ CFREE3 VARCHAR (50), @ CFREE4 VARCHAR (50), @ CFREE5 VARCHAR (50);
DECLARE @ CFREE6 VARCHAR (50), @ CFREE7 VARCHAR (50), @ CFREE8 VARCHAR (50), @ CFREE9 VARCHAR (50), @ CFREE10 VARCHAR (50);
DECLARE @ IQUANTITY decimal (10, 3), @ INUM decimal, @ IBOXQUANTITY decimal (10, 3);
DECLARE @ INTIME DateTime, @ OUTTIME DateTime, @ UPSTATUS SMALLINT, @ CURSTATUS SMALLINT,
DECLARE @ cunitname VARCHAR (50), @ cassitunit VARCHAR (50);
DECLARE @ vdef1 VARCHAR (50), @ vdef2 VARCHAR (50), @ vdef3 VARCHAR (50), @ vdef4 VARCHAR (50), @ vdef5 VARCHAR (50);
DECLARE @ vdef6 VARCHAR (50), @ vdef7 VARCHAR (50), @ vdef8 VARCHAR (50), @ vdef9 VARCHAR (50), @ vdef10 VARCHAR (50);

DECLARE @ COUNT INT. - used to check the stock on hand record number

DECLARE @ errorSun INT - defines error counter
The SET @ errorSun=0 - yes 0

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- START -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

- take to deal with the barcode list
SELECT *
INTO # RdRecordBufferBB
The FROM RdRecordBufferBB
WHERE 1=0

INSERT # RdRecordBufferBB ([cVouchType], [bRdFlag], [Rdsid], [Rdid], [cBarcode], [cInvCode], [cWhCode], [cPosition], [cBatch], [cFree1], [cFree2], [cFree3], [cFree4], [cFree5], [cFree6], [cFree7], [cFree8], [cFree9], [cFree10], [upStatus], [curStatus], [cMadanBarcode], [cunitname], [cassitunit], [iQuantity], [iBoxQuantity], [iNum], [vdef1], [vdef2], [vdef3], [vdef4], [vdef5], [vdef6], [vdef7], [vdef8], [vdef9], [vdef10], [InTime], [OutTime])
SELECT [cVouchType], [bRdFlag], [Rdsid], [Rdid], [cBarcode], [cInvCode], [cWhCode], [cPosition], [cBatch], [cFree1], [cFree2], [cFree3], [cFree4], [cFree5], [cFree6], [cFree7], [cFree8], [cFree9], [cFree10], [upStatus], [curStatus], [cMadanBarcode], [cunitname], [cassitunit], [iQuantity], [iBoxQuantity], [iNum], [vdef1], [vdef2], [vdef3], [vdef4], [vdef5], [vdef6], [vdef7], [vdef8], [vdef9], [vdef10], [InTime], [OutTime]
The FROM RdRecordBufferBB
WHERE cVouchType=@ cVouchType AND Rdid=@ Rdid
The ORDER BY AutoID


Take to deal with the bar code listing inventory,
SELECT DISTINCT T1. *
INTO # T_STOCK_L
The FROM T_STOCK T1 INNER JOIN # RdRecordBufferBB T2
ON T1. CWhCode=T2. CWhCode AND T1. CBarcode=T2. CBarcode AND ISNULL (T1) CFREE1, ' ')=ISNULL (T2) CFREE1, ' ') AND ISNULL (T1) CFREE2, ' ')=ISNULL (T2) CFREE2, ' ') AND ISNULL (T1) CFREE3, ' ')=ISNULL (T2) CFREE3, ' ') AND ISNULL (T1) CFREE4, ' ')=ISNULL (T2) CFREE4, ' ') AND ISNULL (T1) CFREE5, ' ')=ISNULL (T2) CFREE5, ' ') AND ISNULL (T1) CBATCH, ' ')=ISNULL (T2) CBATCH, ");
- AND ISNULL (T1. CPOSITION ')=ISNULL (T2) CPOSITION, ' ') - goods temporarily not consider

- bar code to send and receive processing
DECLARE curOrderReq CURSOR FOR the SELECT BRDFLAG CWHCODE, CINVCODE, CBARCODE, ISNULL (CFREE1, N '), ISNULL (CFREE2, N '), ISNULL (CFREE3, N '), ISNULL (CFREE4, N '), ISNULL (CFREE5, N '),
ISNULL (CFREE6, N '), ISNULL (CFREE7, N '), ISNULL (CFREE8, N '), ISNULL (CFREE9, N '), ISNULL (CFREE10, N '),
ISNULL (CBATCH, N '), ISNULL (CPOSITION, N '),
ISNULL (CMADANBARCODE, N '), ISNULL (IQUANTITY, 0), ISNULL (INUM, 0), ISNULL (IBOXQUANTITY, 0), ISNULL (cunitname, N '), ISNULL (cassitunit, N '), InTime, OutTime, UPSTATUS, CURSTATUS,
ISNULL (vdef1, N '), ISNULL (vdef2, N '), ISNULL (vdef3, N '), ISNULL (vdef4, N '), ISNULL (vdef5, N '), ISNULL (vdef6, N '), ISNULL (vdef7, N '), ISNULL (vdef8, N '), ISNULL (vdef9, N '), ISNULL (vdef10, N ')
The FROM # RdRecordBufferBB; - pending barcode list cursor
The OPEN curOrderReq;

The BEGIN tran - start transaction

The FETCH NEXT FROM curOrderReq INTO @ BRDFLAG, @ CWHCODE, @ CINVCODE, @ CBARCODE, @ CFREE1, @ CFREE2, @ CFREE3, @ CFREE4, @ CFREE5,
@ CFREE6, @ CFREE7 @ CFREE8, @ CFREE9, @ CFREE10,
@ CBATCH @ CPOSITION,
@ CMADANBARCODE @ IQUANTITY, @ INUM, @ IBOXQUANTITY, @ cunitname, @ cassitunit, @ INTIME, @ OUTTIME. @ UPSTATUS, @ CURSTATUS,
@ vdef1, @ vdef2 @ vdef3, @ vdef4, @ vdef5, @ vdef6, @ vdef7, @ vdef8, @ vdef9, @ vdef10
- insert into b_log (c1, c2) values (@ BRDFLAG, @ @ FETCH_STATUS);
WHILE @ @ FETCH_STATUS=0
The BEGIN
-
---->> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
IF (@ BRDFLAG=0) -
The BEGIN
The SET @ COUNT=0;
DECLARE curCurrentStock1 CURSOR FOR the SELECT AUTOID
The FROM # T_STOCK_L WHERE CWHCODE=@ CWHCODE AND CINVCODE=@ CINVCODE AND CBARCODE=@ CBARCODE AND ISNULL (CFREE1, N ')=@ CFREE1 AND ISNULL (CFREE2, N ')=@ CFREE2 AND ISNULL (CFREE3, N ')=@ CFREE3 AND ISNULL (CFREE4, N ')=@ CFREE4 AND ISNULL (CFREE5, N ')=@ CFREE5 AND ISNULL (CBATCH, N ')=@ CBATCH; - barcode standing crop cursor - AND ISNULL (CPOSITION, N ')=@ CPOSITION goods temporarily not consider

The OPEN curCurrentStock1;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related