在MySql存储过程中,我想捕获并记录可能发生的任何错误,然后停止/终止/退出调用存储过程的进程。该过程是另一个存储过程一个或可能两个等级,由预定事件执行。
目前我有第一部分,但不是第二部分:
DECLARE exit HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
@P1 = MYSQL_ERRNO, @P2 = MESSAGE_TEXT;
insert into ErrorLog
SELECT
now() as datetime
, 'spname' as 'StoredProcName'
, @P1 as 'MYSQL_ERRNO'
, @P2 as 'MESSAGE_TEXT';
-- something here to kill the process that this SP is part of?
END;