Ignoring a condition in an SQL procedure

You can specify that you want to ignore errors or warnings within a particular scope of statements in an SQL procedure. However, do so with caution.

Procedure

To ignore a condition in an SQL procedure:

Declare a condition handler that contains an empty compound statement.

Example

The following example shows a condition handler that is declared as a way of ignoring a condition. Assume that your SQL procedure inserts rows into a table that has a unique column. If the value to be inserted for that column already exists in the table, the row is not inserted. However, in this case, you do not want Db2 to notify the application about this condition, which is indicated by SQLSTATE 23505.
     DECLARE CONTINUE HANDLER FOR SQLSTATE '23505'         
       BEGIN  -- ignore error for duplicate value 
       END;