Since: PMD 5.1
Priority: Medium (3)
"WHEN OTHERS THEN NULL" hides all errors - (Re)RAISE an exception or call RAISE_APPLICATION_ERROR
This rule is defined by the following XPath expression:
//ExceptionHandler[QualifiedName/@Image='OTHERS'][count(Statement)=1][Statement/UnlabelledStatement/Expression/PrimaryPrefix/Literal/NullLiteral]Example(s):
CREATEORREPLACEPACKAGEBODYupdate_planned_hrsISPROCEDUREset_new_planned(p_emp_idINNUMBER,p_project_idINNUMBER,p_hoursINNUMBER)ISBEGINUPDATEemployee_on_activityeaSETea.ea_planned_hours=p_hoursWHEREea.ea_emp_id=p_emp_idANDea.ea_proj_id=p_project_id;EXCEPTIONWHENNO_DATA_FOUNDTHENRAISE_APPLICATION_ERROR(-20100,'No such employee or project');ENDset_new_planned;FUNCTIONexisting_planned(p_emp_idINNUMBER,p_project_idINNUMBER)RETURNNUMBERISexisting_hoursNUMBER(4);BEGINSELECTea.ea_planned_hoursINTOexisting_hoursFROMemployee_on_activityeaWHEREea.ea_emp_id=p_emp_idANDea.ea_proj_id=p_project_id;RETURN(existing_hours);EXCEPTIONWHENOTHERSTHENNULL;ENDexisting_planned;ENDupdate_planned_hrs;/Use this rule by referencing it:
<ruleref="category/plsql/bestpractices.xml/TomKytesDespair"/>