In a MySql stored proc I would like to catch and log any error that might occur, then stop/kill/exit the process that called the stored proc. The process being another stored proc one or possibly two levels up, which are executed by a scheduled event.
Currently I have the first part, but not the second:
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;