What Are the Execution Control Statements

Q

What Are the Execution Control Statements? - Oracle DBA FAQ - Understanding PL/SQL Language Basics

✍: FYIcenter.com

A

PL/SQL supports three groups of execution control statements:

  • IF Statements - Conditionally executes a block of statements.
  • CASE Statements - Selectively executes a block of statements.
  • LOOP Statements - Repeatedly executes a block of statements.
  • GOTO Statements - Unconditional changes the execution flow to a specified statement.

The script below shows some execution control statements:

DECLARE
  total NUMBER;
BEGIN
  total := 0;
  LOOP
    total := total+1;
    IF total >= 10 THEN
      GOTO print;
    END IF;
  END LOOP;
  <>
  DBMS_OUTPUT.PUT_LINE('Total counts: ' || TO_CHAR(total));
END;

This script should print this:

Total counts: 10
`

2007-04-30, 4375👍, 0💬