The IF-THEN-ELSE and ELSIF Structures

To be effective, a code block or procedure needs to have commands that allow the developer to document the logic necessary to determine the behavior. Oracle uses conditional logic statements to form the procedure’s behavior. The logic statements come in two forms:

				IF-THEN-ELSE structures
				ELSIF statements
			

The IF-THEN-ELSE Structure

The most common conditional logic device is the IF-THEN-ELSE structure. This is a very powerful device that allows developers to create the most intricate logic. The structure contains required keywords (IF-THEN-END IF) and one optional (ELSE) keyword. The basic structure is as follows:

					If (conditional expression) then
					Statements;
					Else
					Statements;
					End if;
				

The structure begins ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.