Web lists-archives.com

Procedure error handling Best Practice




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