1

Topic: To catch an error dynamic SQL

Good afternoon all.
MySQL 5.6
In a cycle on meta data  FK, I change type,  FK

DECLARE CURSOR1 CURSOR FOR
SELECT table_name, sql_restore_FK
FROM Tmp_Fk_list
WHERE sql_restore_FK is Not NULL
ORDER BY table_name
;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN CURSOR1;
MAIN_LOOP: LOOP
SET @sql1 = v_sql;
# SELECT @sql1;
PREPARE stmt FROM @sql1;
EXECUTE stmt;

1?) whether it is possible to catch an error
SHOW ERRORS;
SELECT @@ error_count;
To see yes I see - and as in variable to write down
2?) as it is possible  an error - .   to write down in a broad gull-table and to continue performance
To write down all errors instead of to be interrupted on 1st of them.

2

Re: To catch an error dynamic SQL

Gulin Feodor, https://dev.mysql.com/doc/refman/5.6/en … ndler.html
Write continue handler which will write to a broad gull.

3

Re: To catch an error dynamic SQL

LiveMan wrote:

Gulin Feodor, https://dev.mysql.com/doc/refman/5.6/en … ndler.html
Write continue handler which will write to a broad gull.

THANKS - likely that that are necessary
Esteemed - but admit I do not know what error
At me in a cycle already is
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
SQLEXCEPTION: Shorthand for the class of SQLSTATE values that do not begin with ' 00 ', ' 01 ', or ' 02 '.
I should describe
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
DECLARE CONTINUE HANDLER FOR SQLWARNING BEGIN END;
And in these 2  ALL possible errors get?

4

Re: To catch an error dynamic SQL

Feodor wrote:

I should describe
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END;
DECLARE CONTINUE HANDLER FOR SQLWARNING BEGIN END;
And in these 2  ALL possible errors get?

Is not present, three are necessary : SQLWARNING (01), NOT FOUND (02) and SQLEXCEPTION (> 02).

5

Re: To catch an error dynamic SQL

Akina;
SUPER Thanks
And it is possible to catch the text of an error?

6

Re: To catch an error dynamic SQL

Feodor wrote:

and the text of an error it is possible to catch?

Well unless through SHOW ERRORS...