fastread homefastrread library fastread menu

Oracle/PLSQL : GOTO Statement

Tutorial by:      Date: 2016-04-15 05:12:55

❰ Previous Next ❱

This Oracle tutorial explains how to use the GOTO statement in Oracle with syntax and examples.


The GOTO statement causes the code to branch to the label after the GOTO statement.


The syntax for the GOTO statement in Oracle/PLSQL consists of two parts - the GOTO statement and the Label Declaration:

GOTO statement

The GOTO statement consists of the GOTO keyword, followed by a label_name.

GOTO label_name;

Label Declaration

The Label Declaration consists of the label_name encapsulated in << >>, followed by at least one statement to execute.



  • label_name must be unique within the scope of the code.
  • There must be at least one statement to execute after the Label Declaration.


Let's look at an Oracle example that uses the GOTO statement.

CREATE OR REPLACE Function FindCourse
   ( name_in IN varchar2 )
   RETURN number
   cnumber number;

   CURSOR c1
     SELECT MAX(course_number)
     FROM courses_tbl
     WHERE course_name = name_in;


   open c1;
   fetch c1 into cnumber;

   IF c1%notfound then
      GOTO default_number;

      GOTO increment_number;
   END IF;

   cnumber := 0;

   cnumber := cnumber + 1;

   close c1;

RETURN cnumber;


In this GOTO example, we have created two GOTO statements. The first one is called default_number and the second one is called increment_number.

❰ Previous Next ❱


Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website