mysql C API bulk inserts
I want to send bulk updates to the MySQL using C APIs. If any of these failed I need to know which one is failed. Wh开发者_运维问答at is the option for this? Can I use the multiple statement command in my_query() or can I use multiple inserts? In both of these cases I failed to find how to retrieve the exact row which is failed (due to duplicate key)
If bulk inserts are used, the command fails if insertion of one of the records fails. In this case no lines will be inserted, and you will get an error with the text that contains the duplicate value.
For example:
INSERT INTO table10 VALUES (1), (2), (3);
ok
INSERT INTO table10 VALUES (4), (1), (2);
Duplicate entry '1' for key 'PRIMARY'
Also, you can use an IGNORE option in the INSERT statement to ignore all errors.
精彩评论