Home

FORALL statements should use the SAVE EXCEPTIONS clause

Rule description

  • FORALL statements should use the SAVE EXCEPTIONS clause

 

Non-compliant Code Example

BEGIN
  FORALL j IN CUSTOMER_TABLE.FIRST..CUSTOMER_TABLE.LAST          --Compliant code (FORALL statements does not used SAVE EXCEPTIONS clause)
    UPDATE CUSTOMERS SET minimunExpense = 1800
    WHERE 100 < CUSTOMER_TABLE(j);
 
EXCEPTION
  WHEN OTHERS THEN
    error_message := SQLERRORMSG;
    DBMS_OUTPUT.PUT_LINE (error_message);
 
    COMMIT;  
    RAISE;
END;

Compliant Code Example

BEGIN
  FORALL j IN CUSTOMER_TABLE.FIRST..CUSTOMER_TABLE.LAST SAVE EXCEPTIONS  --Compliant code (FORALL statements used SAVE EXCEPTIONS clause)
    UPDATE CUSTOMERS SET minimunExpense = 1800
    WHERE 100 < CUSTOMER_TABLE(j);
 
EXCEPTION
  WHEN OTHERS THEN
    error_message := SQLERRORMSG;
    DBMS_OUTPUT.PUT_LINE (error_message);
 
    COMMIT;  
    RAISE;
END;
Visual Expert 2020
 VEPLSQLRULE18