CTL-11: Label and highlight GOTOs if using this normally unnecessary construct.
I suppose that it was thorough of Oracle to include a GOTO statement in the PL/SQL language. This statement, however, should generally be avoided, as it leads to unstructured code design that is hard to analyze and debug.
There are scenarios in which a GOTO can be justified; these mostly relate to going into existing spaghetti code to fix a bug or enhance the code. For an extensive review of GOTO-related issues, see Chapter 16 in Steve McConnell’s book, Code Complete.
Here is a use of GOTO that calls attention to itself:
CREATE OR REPLACE PROCEDURE someone_elses_mess /* || Author: Longgone Consultant || Maintained by: Sad Employee || || Modification History || When Who What || -------------------------------------------- || 11/2000 Sad E. Fixed bug in overdue logic. || Used GOTO to bypass Gordian || Knot of code left by L.C. */ IS BEGIN IF ... THEN IF ... THEN FOR rec IN cur LOOP-- 11/2000 Bypass with GOTO
GOTO <<quick_exit>>
END LOOP; ... lots more code END IF;-- 11/2000 GOTO Target
<<quick_exit>>
END IF;