Labels and the GOTO Statement : GOTO « PL SQL Statements « Oracle PL/SQL Tutorial

The GOTO statement can unconditionally branches to a statement label.

Statement labels are identifiers of a block of code.

Statement labels can be accessed directly by the GOTO statement.


The label is surrounded by double brackets << >>.

The label must not have a semicolon after the label name.

The Syntax for the GOTO Statement

GOTO label_name;

label_name is the matching label_name that must be contained within the same PL/SQL block of code.

Scoping Rules for the GOTO Statement

The GOTO destination must be in the same block, at the same level as or higher than the GOTO statement itself.

The label must be within the same scope as the GOTO statement itself.

Conditions that would cause Oracle to not compile the PL/SQL code include

  1. Jumping into a lower level block
  2. Jumping into a loop
  3. Jumping into an IF statement
  4. Using GOTO to jump from one part of an IF statement to another
  5. Jumping from an exception handler back to a current block of PL/SQL code

Quote from:

Sams Teach Yourself PL/SQL in 21 Days (2nd Edition)

# Paperback: 720 pages

# Publisher: Sams; 2nd edition (December 23, 1999)

# Language: English

# ISBN-10: 0672317982

# ISBN-13: 978-0672317989

22.5.1.Labels and the GOTO Statement
22.5.2.An Example of the GOTO Statement
22.5.3.GOTO statement
22.5.4.Demonstrate GOTO
22.5.5.FOR LOOP with label
22.5.6.JUMP out of a IF statement