Oracle PL/SQL: If-Then-Else, For Loop, While Loop

How it works: if, elsif, else (then) (Click on the images to see them clearly)

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems024.htm

Example:

Ref: https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/13_elems024.htm

Oracle: CASE, WHEN, THEN

Simple:

Searched:

Else:

Reverse For Loop

Ref: For Loop Examples in Oracle

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/controlstatements.htm#BABEFFDC

Oracle While Loop

While loop example from the referenced url

DECLARE
done BOOLEAN := FALSE;
BEGIN
WHILE done LOOP
DBMS_OUTPUT.PUT_LINE (‘This line does not print.’);
done := TRUE; — This assignment is not made.
END LOOP;

WHILE NOT done LOOP
DBMS_OUTPUT.PUT_LINE (‘Hello, world!’);
done := TRUE;
END LOOP;
END;
/

Ref: https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/plsql-control-statements.html#GUID-3F69F563-BCAE-4D3E-8E03-F53C8D64D093