将SQLException上的错误记录到表中

时间:2014-07-03 19:15:15

标签: mysql sql mariadb

我的存储程序总体上是这样的:

BEGIN
    DECLARE exit handler for sqlexception
    BEGIN
        SHOW ERRORS; # this shows a result set with the errors that occured
        ROLLBACK; # this rollbacks all the magic i tried to to, making this whole stuff atomic, YAY! 
    insert into LogTest select 1,2; # this is just a test to make sure it would work
    END;

    START TRANSACTION;
    # do some magic
    COMMIT
END

现在,我需要做的是将Handler更改为类似的东西,显然是 半伪代码

DECLARE exit handler for sqlexception
    BEGIN
        ROLLBACK; # this rollbacks all the magic i tried to to, making this whole stuff atomic, YAY! 
    insert into LogTest # and this tells me what timey whimey hit the maelstorm
    select now(),*,'some id', ... <some more stuff maybe?>
      from (Show errors) as Errors
END;

任何一个经验/想法/知识?

0 个答案:

没有答案