Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский Português 中文
Showing entries 1 to 3

Displaying posts with tag: mysql_errno (reset)

Improve your Stored Procedure Error Handling with GET DIAGNOSTICS
+0 Vote Up -0Vote Down

In a previous post, I discussed debugging stored procedures with RESIGNAL, which is of great value when troubleshooting errors raised by your stored procedures, functions, triggers, and events as of MySQL/MariaDB 5.5.

However, as of MySQL 5.6 and MariaDB 10.0, there is GET DIAGNOSTICS, which can be used to get the exact error details as well.

RESIGNAL just outputs the error, as it comes from the server, for instance:

ERROR 1146 (42S02): Table 'db1.t1' doesn't exist

read more

Improve your Stored Procedure Error Handling with GET DIAGNOSTICS
+1 Vote Up -0Vote Down

In a previous post, I discussed debugging stored procedures with RESIGNAL, which is of great value when troubleshooting errors raised by your stored procedures, functions, triggers, and events as of MySQL/MariaDB 5.5.

However, as of MySQL 5.6 and MariaDB 10.0, there is GET DIAGNOSTICS, which can be used to get the exact error details as well.

RESIGNAL just outputs the error, as it comes from the server, for instance:

ERROR 1146 (42S02): Table 'db1.t1' doesn't exist

You may not want the error just written to the console, or perhaps you want to at least control how it is written.

It’s common to see exit handler code in the following form:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SELECT ...;
END;

Where the SELECT outputs something not very useful in many cases.

With GET DIAGNOSTICS, you can

  [Read more...]
Error handling for MySQL applications
+0 Vote Up -0Vote Down
When connecting to MySQL, or executing a query, proper error handling is required. Many take this very seriously, and do a construct like mysql_connect() or die() or the equivalent with mysql_query(). For web apps this generally makes error codes end up on the user page, you can easily see this by doing a Google search for some of the common error texts. Slightly improved apps are nicer to the user and log the error separately.

But both approaches fail, fundamentally, as they don't take into account that not all errors are the same and, most importantly, many error are not fatal but require other forms of action. So let's look at that, look at what causes the errors so you truly understand that it's not fatal stuff, and how you can handle them.

When you get a "not successful" response back from a MySQL API function, you first need find out what the error is



  [Read more...]
Showing entries 1 to 3

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.