Fixed bill_id separation strategy in the stored procedure of net Bank voucher

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.