Writing Control Structures
IF and CASE
IF cond THEN ... ELSIF cond THEN ... ELSE ... END IF; - note ELSIF is one word, END IF is two. CASE has a simple form (CASE deptno WHEN 10 THEN ...) and a searched form (CASE WHEN sal > 1000 THEN ...). A CASE expression with no matching branch and no ELSE raises CASE_NOT_FOUND (ORA-06592), whereas an unmatched IF simply does nothing.
Loop forms
A basic LOOP ... END LOOP relies on EXIT or EXIT WHEN inside the body; if you forget it, the loop runs forever. WHILE cond LOOP tests before each iteration, so the body can run zero times. A numeric FOR i IN [REVERSE] low..high LOOP implicitly declares i as an integer, scopes it to the loop, and makes it read-only - assigning to it raises PLS-00363. The bounds are evaluated once at entry, and an empty range simply skips the body without error.
Labels, EXIT and CONTINUE
<<outer>> labels let an inner loop exit or continue a specific enclosing loop; the label must immediately precede the LOOP keyword. CONTINUE [label] WHEN condition (11g) jumps to the next iteration.
The NULL trap
A condition evaluating to NULL is treated as false by IF, WHILE and EXIT WHEN. An unassigned BOOLEAN variable therefore silently skips both branches.
Rule of thumb: use a cursor FOR loop or a WHILE with an explicit termination test rather than a bare LOOP, and always test IS NULL explicitly when a variable's initialisation is not guaranteed.