RE: continue oracle 11g verses 10g

From: Mark W. Farnham <mwf_at_rsiz.com>
Date: Fri, 28 Dec 2012 10:32:01 -0500
Message-ID: <00c501cde510$7c57f8f0$7507ead0$_at_rsiz.com>



Chiming in just to mention that elimination of GOTO statements is not a very useful goal.

"The unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress. ... The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program."

The problem of GOTO is well expressed in this tiny extract and abbreviation of Edsger Dijkstra's letter Go To Statement Considered Harmful.

Leaving to the reader the homework of digging up the proofs that:

  1. Any logic formed by IF.THEN.ELSE, DO.WHILE, and EXIT/CONTINUE can be simulated in a structured template quite simply with LABEL.GOTO and
  2. The reverse, with GOTOs only forming downward branching blocks, exit/continues, and loop tests.

(IF you can find a copy of the sBASIC manual, Steve Garland, et. al,
Dartmouth College, circa 1980, I think these proofs are clearly articulated with examples targeting folks converting from BASIC6 to structured BASIC).

The move advocated by Dijkstra, rather, was to provide the programming language constructs to facilitate structured programming to avoid the spaghetti that can easily arise from "The unbridled use of the go to statement." While we can write spaghetti code in pretty much any language, the temptation to just make a little patch here (or "invitation" as Dijkstra wrote) is very high with GOTO.

Simply avoid that temptation, and if you're in a multi-version situation where some of the important components (exit/continue in this case) of simulating GOTO logic for structured programming is missing, go ahead and use the GOTO logic and keep it clean and predictable.

Clean readability so that the casual reader can follow the logic seems a better goal than elimination of GOTO statements. Excess logic to avoid structured use of GOTO seems unlikely to make the code easier to read and understand.

mwf

-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Patterson, Joel
Sent: Friday, December 28, 2012 7:46 AM
To: Patterson, Joel; oracle-l; Jared Still; tim_at_evdbt.com Subject: RE: continue oracle 11g verses 10g

Jared,

[Pasted your response in original posting here.]

Yes, I looked at
http://www.oracle.com/technetwork/database/features/plsql/overview/plsql-con ditional-compilation-133587.pdf However, I'm not 'getting it' fast enough.
(I like working examples I can follow from the beginning). If you have
something more or better on the Conditional Compilation, send it along.

However I thought last night, that what I could do is take the conditions that are deciding whether to continue or not, and put them into a function. Then ignore one of the options. In this particular case I believe the GOTO can be eliminated -- as well as the CONTINUE infact. :) The things you think of when you're not working the problem.

It would look Something like this -- the function will return True or False. If LOOPDONE then

   Print something.
END IF

  • here the loop would continue with next iteration.

Thanks,
....

On Thu, Dec 27, 2012 at 11:08 AM, Patterson, Joel <Joel.Patterson_at_crowley.com> wrote:
I have a function (Solaris 5.10, all versions of oracle), that I wish the same code to compile and run on oracle versions 9, 10, and 11. (you can dismiss 9 however).

CONTINUE was introduced in 11g. Before 11g, there were various work arounds, but in my case I'll use the goto <<label>> method (ie 10g).

Joel, have you considered conditional compilation?

Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist Oracle Blog: http://jkstill.blogspot.com Home Page: http://jaredstill.com

-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Patterson, Joel
Sent: Thursday, December 27, 2012 2:08 PM To: oracle-l
Subject: continue oracle 11g verses 10g

I have a function (Solaris 5.10, all versions of oracle), that I wish the same code to compile and run on oracle versions 9, 10, and 11. (you can dismiss 9 however).

CONTINUE was introduced in 11g. Before 11g, there were various work arounds, but in my case I'll use the goto <<label>> method (ie 10g).

I want the for loop to continue iterating regardless of the version. I started looking at PL/SQL conditional compilations Oracle 2005, http://www.oracle.com/technetwork/database/features/plsql/overview/plsql-con ditional-compilation-133587.pdf but looks like it is either not right or too complicated for this. Execute immediate also does not appear to work inside the function for this task.

What to the listers recomend?

For I ...
<<message loop>>
... do stuff...

          if v_oracle11g then
--            execute immediate 'continue'; 
            continue; 
          else 
--            execute immediate 'goto message_loop'; 
            goto message_loop; 
          end if;

end loop;

Joel Patterson
Database Administrator
904 727-2546

--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l
Received on Fri Dec 28 2012 - 16:32:01 CET

Original text of this message