I created a procedure in which if the input is equal to 0, the procedure will throw an SQLException with an error message of 'dwa'.
CREATE PROCEDURE enter_the_dragon(test INT)
BEGIN
DECLARE test_error CONDITION FOR SQLSTATE '42123';
IF test = 0 THEN
SIGNAL test_error
SET MESSAGE_TEXT = 'dwa';
END IF;
END;
I am aware that SQLSTATE value '00000' means there's no error and SQLSTATE that starts with '01' is a warning. Does that mean that every SQLSTATE that doesn't collide with these two rules is an error?
Considering this rules, are there any other rules on SQLSTATE? Format? Or I am free to create my own SQLSTATE (ex. 01123 (warning) etc.)?
Had the same problem, look at: http://dev.mysql.com/doc/refman/5.5/en/signal.html
= '00' (success)
= '01' (warning)
= '02' (not found)
> '02' (exception)