G-5020: Never handle unnamed exceptions using the error number.

Critical

Maintainability

Reason

When literals are used for error numbers the reader needs the error message manual to unterstand what is going on. Commenting the code or using constants is an option, but it is better to use named exceptions instead, because it ensures a certain level of consistency which makes maintenance easier.

Example (bad)

DECLARE
   co_no_data_found CONSTANT INTEGER := -1;
BEGIN
   my_package.some_processing(); -- some code which raises an exception
EXCEPTION
   WHEN TOO_MANY_ROWS THEN
      my_package.some_further_processing();
   WHEN OTHERS THEN
      IF SQLCODE = co_no_data_found THEN
         NULL;
      END IF;
END;
/

Example (good)

BEGIN
   my_package.some_processing(); -- some code which raises an exception
EXCEPTION
   WHEN TOO_MANY_ROWS THEN
      my_package.some_further_processing();
   WHEN NO_DATA_FOUND THEN
      NULL; -- handle no_data_found
END;
/