PL/SQL If-Then-Else Statement

PL/SQL If-Then-Else Statement

Oracle PL/SQL allow the following statements: if, if else, if elsif.

if – then

If a = 5 Then
   ... 
End If;

if – then – else

If b = 10 Then
    ... 
Else
    ... 
End If;

if – then – elsif

If c = 15 Then
    ...
ElsIf c = 16 Then 
    ... 
Else
    ... 
End If;

Example:

 
DECLARE
	c varchar2(30);
BEGIN
	IF c IS NULL THEN
		DBMS_OUTPUT.PUT_LINE('Value of c is null.');
	ELSE
		DBMS_OUTPUT.PUT_LINE('Value of c is not null.');
	END IF;
END;