Header Ads

Oracle PL/SQL GOTO Example

The PL/SQL GOTO statement provides an unconditional transfer of control to a labeled statement or block within the same subprogramWhile it allows for direct jumps in code execution, its use is generally discouraged in modern programming practices due to potential negative impacts on code readability, maintainability, and debugging.


Example:

DECLARE

  x NUMBER := 1;

BEGIN

  IF x = 1 THEN

    GOTO my_label;

  END IF;


  DBMS_OUTPUT.PUT_LINE('This will not print');


  <<my_label>>

  DBMS_OUTPUT.PUT_LINE('GOTO jumped to this label');

END;

/


No comments

Powered by Blogger.
/* my inputted*/