How to check if INSERT went well in stored function?
问题 I'm creating a stored function which should insert new row to table. In this table is also one unique column. How can I check if everything goes well and row really was inserted? How can I check exactly that it's this unique column found (for example - try to add duplicate value)? 回答1: You can check the LAST_INSERT_ID() function and INSERT IGNORE. If the INSERT IGNORE was successful, you get the primary key returned. Let's create a table with an auto increment primary key and a unique key on