MySQL Forums
Forum List  »  MySQL Workbench

Every Attempt at Error Handling Fails with GET statement
Posted by: David Allen
Date: December 02, 2019 11:42AM

I'm using MySQL 8.x and every attempt at putting any error handling that provides internal details fails on the 'GET' (red highlight) stating:

"GET is not valid at this position"

Yet all of this code is all over the internet. Note this happens with any error handling code that has the keyword 'GET' in it, and the code works just fine in dbfiddle.

If I put in the following, it all works fine (because there is no 'GET') - but this doesn't provide the actual error message the system is producing:

DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN SELECT 'SQL Exception:act_account_main_verify' Message; END;

Just this code alone causes the error as well; an empty routine with nothing but the error handler in it:

CREATE PROCEDURE 'routine1' ()
SET @full_error = CONCAT("SQL Exception:act_account_main_create:", @errno, " (", @sqlstate, "): ", @text);
SELECT @full_error;

I tried using locally 'DECLARE'd variables, instead of user '@variable's, for assignment in 'GET DIAGNOSTICS'. No difference.

I'm running the latest version of the Workbench Editor and MySQL Local CE Server (latest version).

I wonder if there's some core SQL setting that enables a 'GET' within a 'SQLEXCEPTION' that perhaps isn't enabled? Or is it because I'm using CE vs. SE?

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

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.