sourcetip

SQLException 오류를 테이블에 기록

fileupload 2023. 9. 15. 21:18
반응형

SQLException 오류를 테이블에 기록

전반적으로 다음과 같은 절차를 저장했습니다.

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

이제 핸들러를 이런 식으로 바꾸는 것이 필요합니다. 분명히 반의사 코드입니다.

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;

경험/아이디어/지식이 있는 사람?

언급URL : https://stackoverflow.com/questions/24561666/log-errors-on-sqlexception-to-table

반응형