MySQL Forums
Forum List  »  Stored Procedures

error handling - what happens if you don't know the error number !
Posted by: Peter Larb
Date: January 05, 2006 10:36PM

Good afternoon

firstly apologies from my misunderstanding of the manuals referred to below but I am after a clear guide here and am a little confused- thanks.



I am posting this message after much research into error handling in MySQL.

I am trying to determine the best replacement for the following :

MS SQL Server equivalent:


If @@error = 0 then ........


I need to know how I can create such a GENERAL error handler in MySQL.

Now from what I have read:

1. DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;

refer: http://dev.mysql.com/doc/refman/5.0/en/declare-handlers.html

condition_value:
SQLSTATE [VALUE] sqlstate_value
| condition_name
| SQLWARNING
| NOT FOUND
| SQLEXCEPTION


the examples I have all read all use error handling and refer to SPECIFIC error numbers.

The other problem I have is that if I was to use:

DECLARE CONTINUE HANDLER FOR SQLEXCEPTION;

this will only work when the error does not fall under "warning", "not found" see above link

2. The problem:

what happens if you don't know the error number !

what do you do ?

So what I want to happen is:

If there is ANY error pass me back "-1" for example, or pass me back my custom message


Thankyou muchly

Peter

Peter Larb

Options: ReplyQuote


Subject
Views
Written By
Posted
error handling - what happens if you don't know the error number !
2290
January 05, 2006 10:36PM


Sorry, you can't reply to this topic. It has been closed.

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.