MySQL Forums
Forum List  »  Stored Procedures

Re: Inserting errors into logs
Posted by: Peter Brawley
Date: April 22, 2020 02:45PM

See Get Diagnostics in the manual, it supports something like ...

drop table if exists t;
create table t(i int);
drop procedure if exists p;
delimiter go
create procedure p()
begin
  Declare Exit Handler for SqlException
    begin
      Get Diagnostics Condition 1 
        @sqlstate = Returned_SqlState,
        @errno = Mysql_Errno, 
        @text = Message_Text;
      Select @sqlstate, @errno, @text;
    end;
  insert into t set i="thisisastring";
end;
go
delimiter ;
call p();
drop table t;

Options: ReplyQuote


Subject
Views
Written By
Posted
295
April 20, 2020 07:10AM
129
April 20, 2020 11:29AM
107
April 22, 2020 06:58AM
Re: Inserting errors into logs
120
April 22, 2020 02:45PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.