Database batch write judgment problems

Source: Internet
Author: User
Database batch write judgment problems I do a function is an order import function, the data in the xls is imported into mysql, each time about 1000. the problem is that each record has an encoding. First, check whether the encoding system has been set up and imported, if the entire batch is not imported into the system, what should I do ?? Database batch write judgment problems
My function is an order import function. I will import the data in xls to mysql, with about 1000 entries each time.

The problem is that each record has an encoding. First, check whether the encoding system has been set up and imported, if the entire batch is not imported into the system, what should I do ??
------ Solution --------------------
I don't understand. each record has a single encoding, but this encoding is not properly configured. Why can't I import the entire batch? Isn't this one?
If the one I want cannot be imported, do the following:
Read the 1000 pieces of data from the XLS file, read the encoding table from the database, create an array using the encoding as the primary key, and then read your 1000 pieces of data cyclically, each time you use the encoding of this data to find whether the encoding array exists. if it does not exist, it is skipped. if it exists, it is saved to the database. Of course, you can write SQL statements and save them at the last time.
------ Solution --------------------
It's nothing to look!
It is easy to implement.
First check whether the encoding exists (select)
Insert based on the result)

Obviously, your system uses a foreign key (it is purely for yourself)
In fact, direct insertion does not matter. it is not an error or the insertion is 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.