开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜