Oracle PL/SQL - Clumsy IF statements

Introduction

Avoid clumsy IF statements such as:

IF new_balance < minimum_balance THEN 
 overdrawn := TRUE; 
ELSE 
 overdrawn := FALSE; 
END IF; 

Instead, assign the value of the BOOLEAN expression directly to a BOOLEAN variable:

overdrawn := new_balance < minimum_balance; 

A BOOLEAN variable is either TRUE, FALSE, or NULL. Do not write:

IF overdrawn = TRUE THEN 
 RAISE insufficient_funds; 
END IF; 

Instead, write:

IF overdrawn THEN 
 RAISE insufficient_funds; 
END IF; 

Related Topic