Procedure error handling Best Practice
Michael Moore <[email protected]> Wed, 28 Feb 2018 13:51:21 -0800
| Newsgroups | gmane.comp.db.mysql.general |
|---|---|
| Message-ID | <B1445B9FB6BD75439CD95529BB4F10D51A2D68DFD7@QSEMAIL.echo.quinstreet.net> |
Long time Oracle PL/SQL coder but new to MySQL.
I have an error handler that looks like this ...
declare continue handler for sqlexception
begin
get diagnostics condition 1 @p3 = returned_sqlstate, @p4 = message_text;
set v_there_was_an_error_while_inserting_a_lead_summary := true;
insert into rit.rit_audit_message(severity,
message,
process_name,
summary_detail_map,
createdby2qmp_user,
updatedby2qmp_user)
values ('ERROR',
concat('Something went wrong while trying to insert commission lead summaries. No summaries created! ',
@p3,
' ',
@p4),
'pop_comm_summary',
1003,
1003);
end;
So, what if the insert (shown above) throws a sqlexception?
1) What happens?
2) Is there a better way to do this? Perhaps I should not have DML in my error block?
Michael Moore