RE: PL/SQL best practices ? How to go to end of loop (i.e. next record)

From: Dunbar, Norman (Capgemini) <"Dunbar,>
Date: Thu, 10 Feb 2011 13:50:36 -0000
Message-ID: <919FC80F27E0C6428106496EDF92A752112EE33E_at_EXCCLUS05.PRODDS.NTNL>



Afternoon all,

>> Avoid goto at all cost.

Hmmm.

>> http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To
>> _Considered_Harmful.html

Hmmm. Edgar has a valid point, but I'm loath to support the "avoid at all costs" proposition.

What's the difference between "EXIT" and "GOTO" to exit from a loop? Nothing other than semantics in my opinion. Both jump from current point of execution to the end of the loop. Job done. They are, in effect, both GOTOs.

CONTINUE [WHEN] and GOTO are also similar, both jump back to the start of the loop. In effect, they are both GOTOs.

So, having said that, I haven't used a GOTO yet in any of my PL/SQL programming. I use them all the time in my assembly stuff - no other choice really!

What Edgar (and Toon) possibly should have said is "avoid GOTO whenever possible, however, be aware that there are times when using one will make your code more readable and easier to write."

The Linux source code uses it quite frequently and effectively and it does make the source far easier to read.

I've seen programmers with a total aversion to using GOTO write code with so many nested IFs that it became quite difficult to figure out where you were and what you were attempting to do. Whereas the use of a simple GOTO would have saved lots of typing and heart ache.

Use GOTO, but only when it's the correct choice. Never say never! (Sorry, I just did!)

<Dons flame proof suit, sits back, and waits ....>

Cheers,
Norm.

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Feb 10 2011 - 07:50:36 CST

Original text of this message