user1226868
user1226868

Reputation: 1758

MySQL stored procedure, do not ever raise error?

I would like to make a Stored procedure in MySQL with an try/catch to prevent the error going to my java project. But since there is no try/catch in MySQL im searching for alternatives.

The only thing i need to prevent, is to dont get a "Duplicate key" error from mysql in my java project. If i get this error, i dont want to show anything and act like it has inserted normal.

Is this possible?

Upvotes: 1

Views: 1060

Answers (1)

Mchl
Mchl

Reputation: 62395

Why don't you catch this error withi your application?

Anyway, from docs: http://dev.mysql.com/doc/refman/5.5/en/insert.html

If you use the IGNORE keyword, errors that occur while executing the INSERT statement are treated as warnings instead. For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the row still is not inserted, but no error is issued

.

Upvotes: 2

Related Questions