Condition Handling +-------+------------------------------------+ | 42S02 | Unknown table ’test.no_such_table’ | +-------+------------------------------------+ Statement information: row count ... other statement information items ... Condition area list: Condition area 1: error code for condition 1 error message for condition 1 ... other condition information items ... Condition area 2: error code for condition 2: error message for condition 2 ... other condition information items ... Condition area 3: error code for condition 3 error message for condition 3 ... other condition information items ... For a statement that produces three conditions, the diagnostics area contains statement and condition information like this: For a description of the diagnostics area, see Section 13.6.7.7, “The MySQL Diagnostics Area” . Briefly, it contains two kinds of information: This extension applies only to the current diagnostics area. It does not apply to the second diagnostics area because  GET STACKED DIAGNOSTICS  is permitted only if the current context is a condition handler. If that is not the case, a  GET STACKED DIAGNOSTICS when handler not active  error occurs. •Condition information, such as the error code and message. If a statement raises multiple conditions, this part of the diagnostics area has a condition area for each one. If a statement raises no conditions, this part of the diagnostics area is empty. •Statement information, such as the number of conditions that occurred or the affected-rows count. •To obtain statement information, retrieve the desired statement items into target variables. This instance of  GET DIAGNOSTICS  assigns the number of available conditions and the rows-affected count to the user variables  @p1  and  @p2 : •To obtain condition information, specify the condition number and retrieve the desired condition items into target variables. This instance of  GET DIAGNOSTICS  assigns the SQLSTATE value and error message to the user variables  @p3  and  @p4 : 2812 Valid  target  designators for storing item information can be stored procedure or function parameters, stored program local variables declared with  DECLARE , or user-defined variables. The retrieval list specifies one or more  target  =  item_name  assignments, separated by commas. Each assignment names a target variable and either a  statement_information_item_name  or condition_information_item_name  designator, depending on whether the statement retrieves statement or condition information. GET DIAGNOSTICS  can obtain either statement or condition information, but not both in the same statement: GET DIAGNOSTICS @p1 = NUMBER, @p2 = ROW_COUNT; GET DIAGNOSTICS CONDITION 1 @p3 = RETURNED_SQLSTATE, @p4 = MESSAGE_TEXT;