MariaDB 存储过程错误处理程序

MariaDB stored procedure error handler

我想为存储过程编写一个通用的捕获所有错误处理程序。有没有办法捕获抛出错误的代码和描述?

    DECLARE EXIT HANDLER FOR SQLEXCEPTION
        CALL procLogError('SQL Exception code' || somecode || ': ' || description);

我写了一个记录错误的过程,在上面的例子中,'somecode' 和 'description' 将被替换为实际值(如果可用)。

已解决,此信息很难找到,而且在我拥有的任何一本书中都找不到。

https://mariadb.com/blog/improve-your-stored-procedure-error-handling-get-diagnostics