我想在单独的表中记录触发器、过程和函数的错误/异常。
"我代码如下所示":
CREATE PROCEDURE SILENCE_DB.GET_WEB_APPLICATION_NAVIGATION(_xxx CHAR(32))
BEGIN
-- DECLARE THE EXCEPTION AND WORNING HANDLER
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS @_no = NUMBER, @row_no = ROW_COUNT;
GET DIAGNOSTICS CONDITION @_no
@sql_sat=RETURNED_SQLSTATE, @errMsg= MESSAGE_TEXT
-- to insert the error on my error table
CALL INSERT_ERROR_TABLE(........);
RESIGNAL;
END;
DECLARE CONTINUE HANDLER FOR SQLWARNING
GET DIAGNOSTICS @_no = NUMBER, @row_no = ROW_COUNT;
GET DIAGNOSTICS CONDITION @_no
@sql_sat=RETURNED_SQLSTATE, @errMsg= MESSAGE_TEXT;
-- to insert the error on my error table
CALL INSERT_ERROR_TABLE(........);
RESIGNAL; -- DECLARE THE NOT FOUND HANDLER
DECLARE CONTINUE HANDLER FOR NOT FOUND
BEGIN
-- NOTHING TO DO
END;
................... business code
................... business code
................... business code
................... business code
END;
但如果我使用RESIGNAL/SIGNAL,我会在控制台上得到错误,但不会插入到表ERRORS中,如果我删除RESIGNAL/SIGNAL,我不会在控制台上得到错误,但会将错误插入到表ERRORS中!!!因此,任何人都可以建议如何实现我的目标。
1条答案
按热度按时间elcex8rz1#
解决方案正如Solarflare所说,使用MyISAM而不是InnoDB来实现INSERT_ERROR_TABLE类型