Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: CONTINUE loop

Re: CONTINUE loop

From: Walter T Rejuney <BlueSax_at_Unforgetable.com>
Date: Tue, 09 Jan 2001 08:21:29 -0500
Message-ID: <3A5B1059.41BB27DC@Unforgetable.com>

Thorsten Kettner wrote:
>
> Hi Walter, thank you for your advice. The problem is that my program is
> much more complicated than my simple example. There are several places
> where I want to branch to the next loop. If I use IFs my code will get
> nested deeper and deeper and will be much worse to read. This is why
> other languages offer a CONTINUE command. I guess there is none
> available in PL/SQL, right?
>

If the logic is that complex then the program should be restructured to put the logic into procedures and functions. If you read books on structured programming virtually all of them will say at some point that if you have more than two levels of "if" statements in a single procedure/function it is virtually a guarantee that something needs to be moved to another procedure and function. Sometimes this takes practice and experience, but after twenty years of doing this stuff I don't know of a single program of mine that has more than two levels of nested "if" statements or loops.

Having said all of that, using labels to simulate "break" and "continue" is perfectly acceptable in PL/SQL and there are no built-in penalties. While I don't have any direct knowledge of this in PL/SQL, I have enough background in assembly language to know that the way in which "break" and "continue" are normally implemented in a high level language is via a JMP to a compiler-generated label and since JMP in assembly is the equivalent to GOTO in a high-level language the only difference is that in the high level language the method is more visible.

Don't listen to what all of the computer-science-weenies say about not using GOTO. It is a good idea to avoid it when possible, but in some situations it just makes better sense then to have convoluted control structures that are unmaintainable. Received on Tue Jan 09 2001 - 07:21:29 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US