TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PL/SQL Goto

PL/SQL goto example for beginners and professionals with examples on cursors, triggers, functions, procedures, strings, exceptions, arrays, collections, packages, transactions etc.

<< Back to PL

PL/SQL GOTO Statement

In PL/SQL, GOTO statement makes you able to get an unconditional jump from the GOTO to a specific executable statement label in the same subprogram of the PL/SQL block.

Here the label declaration which contains the label_name encapsulated within the << >> symbol and must be followed by at least one statement to execute.

Syntax:

GOTO label_name;

Here the label declaration which contains the label_name encapsulated within the << >> symbol and must be followed by at least one statement to execute.

GOTO label_name;
 ..
..
<>
Statement;

Example of PL/SQL GOTO statement

Let's take an example of PL/SQL GOTO statement.

DECLARE
   a number(2) := 30;
BEGIN
   <>
   -- while loop execution 
   WHILE a < 50 LOOP
      dbms_output.put_line ('value of a: ' || a);
      a := a + 1;
      IF a = 35 THEN
         a := a + 1;
         GOTO loopstart;
      END IF;
   END LOOP;
END;
/

After the execution of above code, you will get the following result:

value of a: 30
value of a: 31
value of a: 32
value of a: 33
value of a: 34
value of a: 36
value of a: 37
value of a: 38
value of a: 39
value of a: 40
value of a: 41
value of a: 42
value of a: 43
value of a: 44
value of a: 45
value of a: 46
value of a: 47
value of a: 48
value of a: 49

Statement processed.

Restriction on GOTO statement

Following is a list of some restrictions imposed on GOTO statement.

  • Cannot transfer control into an IF statement, CASE statement, LOOP statement or sub-block.
  • Cannot transfer control from one IF statement clause to another or from one CASE statement WHEN clause to another.
  • Cannot transfer control from an outer block into a sub-block.
  • Cannot transfer control out of a subprogram.
  • Cannot transfer control into an exception handler.
Next TopicPL/SQL Procedure




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf