PL/SQL offers a number of options when it comes to writing conditional logic, as in variations on "If this then that". This post reviews them, and provides examples. You can choose from the following: IF statement - IF, IF-THEN, IF-ELSE, IF-ELSIF-ELSE CASE statement - simple and searched CASE CASE expression - the expression "version" of the statement (and one of my favorite elements of PL/SQL) IF Statement It's hard to imagine a programming language without a version of IF, and PL/SQL is no exception. The IF statement either runs or skips a sequence of one or more statements, depending on a condition. The IF statement can take one of three forms, but they all have this in common: they start with "IF" and then end with "END IF;". IF THEN The simplest IF statement: if the boolean expression evaluates to TRUE then execute the statements between THEN and END IF. Example: BEGIN IF l_hire_date < SYSDATE THEN
For the last twenty years, I have managed to transform an obsession with PL/SQL into a paying job. How cool is that?