Database batch write judgment related issues

Source: Internet
Author: User
Database Batch Write judgment problem
My function is an order import function, the data inside the XLS import into MySQL, each time around 1000.

Now the problem is that each record has a code, I have to check the coding system has not been built, built well, on the import, if not built on this whole batch are not imported system, how should I do??


------Solution--------------------
Not understand, each record a code, but this code is not built well, how to a whole batch can not be imported, not this one can not import it?
If it is the one I want to not import, you can do this:
First read the 1000 data from the XLS file, at the same time read the Code table from the database, to encode the primary key to create an array, and then loop through your 1000 data, each time with this data encoding to find the encoding array in the existence, not exist then skip, the existence is saved into the database. Of course you can write SQL statements last-time save.
------Solution--------------------
It's nothing but trouble.
It's easy to implement, for each piece of content
First check if the encoding exists (select)
Reinsert (insert) based on results

Obviously your system uses a foreign key (it's self-made trouble for yourself)
In fact, direct insertion does not matter, it is not an error or insert invalid

  • 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.