I have a bunch of insert querys running and some of them fail with a duplciate entry.

I want to see a log where it says "Error: Duplicate key" and that tells me the EXACT INSERT query that fails so I can see what keys are duplicated.


Recommended Answers

All 3 Replies

Well, can't you loop through your queries and validate that the correct data is being inserted? You could break the loop when the error occurs, showing you which data is generating the error.

If you are inserting programmatically, you can determine the query failed then log the error and the query that you built to be sent to the server. Of course, you might be inserting a large collection, in which case you will need to use pritaeas' answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.