0

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;
SomeGuy30145
  • 85
  • 1
  • 7

1 Answers1

0

You can use RETURN or EXIT clause. or just use a label to the particular query from the procedure and use LEAVE to exit it. You can perhaps refer here