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
818
April 20, 2020 07:10AM
414
April 20, 2020 11:29AM
416
April 22, 2020 06:58AM
Re: Inserting errors into logs
414
April 22, 2020 02:45PM
391
April 23, 2020 12:38AM


Sorry, you can't reply to this topic. It has been closed.

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.