Origin:
The system generated bill_id length is indeterminate, there may be 32 bits, 36 bits or other, so in the original published network silver, voucher stored procedures, used to separate multiple ticket strategy there is a loophole, previously in accordance with the 32-bit fixed separation, so it will lead if a batch of documents, if a Bill_ ID is a non-32-bit length, then all the tickets from this single back will be split failure, no data.
Solve:
Replace the original two segment with the following two-segment code.
The original loop begins
While LEN (@BILL_ID_LIST) >=32
BEGIN
--Get the current processing number
SET @BILL_ID =left (@BILL_ID_LIST, 32)
Replaced by
While LEN (@BILL_ID_LIST) >1
Begin
--Get the current processing number
If CHARINDEX (', ', @BILL_ID_LIST) <>0
Set @BILL_ID =left (@BILL_ID_LIST, (CHARINDEX (', ', @BILL_ID_LIST))-1)
Else
Set @[email protected]_id_list
--------------------------------------------------
The original loop ends
--Parse the next ticket
IF LEN (@BILL_ID_LIST) >34
SET @BILL_ID_LIST =substring (@BILL_ID_LIST, 34,len (@BILL_ID_LIST)-33)
ELSE
SET @BILL_ID_LIST = ' '
Replaced by
--Parse the next ticket
IF CHARINDEX (', ', @BILL_ID_LIST) <>0
Set @BILL_ID_LIST =substring (@BILL_ID_LIST, CHARINDEX (', ', @BILL_ID_LIST) +1,len (@BILL_ID_LIST)-len (@bill_id) +1)
ELSE
SET @BILL_ID_LIST = ' '
Fixed bill_id separation strategy in the stored procedure of net Bank voucher