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

Home -> Community -> Usenet -> c.d.o.server -> Re: cursor looping - best practices?

Re: cursor looping - best practices?

From: <fitzjarrell_at_cox.net>
Date: Fri, 15 Jun 2007 10:24:10 -0700
Message-ID: <1181928250.869340.8430@q75g2000hsh.googlegroups.com>


On Jun 15, 11:36 am, spacemar..._at_mailinator.com wrote:
> On Jun 15, 11:11 am, sybra..._at_hccnet.nl wrote:
>
> > Obviously this is a version dependent question.
>
> not so obvious at all -- otherwise i would have specified. i was
> unaware of that difference between version. thanks.
>
> > I always failed to see why people posting here assume everyone here
> > is a mindreader and/or keeps track of versions in use.
>
> perhaps i can offer you some insight. i come from the MS SQL world,
> and little has changed over the years... what i learned in 2000 is
> still what i use today in MS SQL, little has changed. in fact its not
> uncommon to find SQL Server 2000 db instances in production use. i
> dont know about previous versions because they are no longer found in
> production in my experiences.
>
> i cant speak for others, but thats why when i ask about a best
> practice its not obviously apparent to me that there may be dramatic
> differences between what people are actively using in production.
>
> > So the best practice is NOT to use CURSOR FOR loops.
>
> interesting. i am reviewing some found-code and i see a technique like
> so:
>
> LOOP
> IF c_someCursor%FOUND THEN
> --doing stuff: CASE value tests, dynamic variable
> assignments..
> END IF
> END LOOP
>
> ...it almost seems like an app programmer style, and not what ive
> typically seen in T-SQL, so im curious about it w/ regards to PL SQL
>
> thanks for the info.
>
> sm

The 'best practices' are, indeed, version dependent, as Sybrand noted. In 8i and earlier releases no other options are available; you're stuck, if you code with PL/SQL, using loops for multi-record sets. 9i and later releases offer array processing, and 10g has improved upon what 9i offered.

For recent releases of Oracle cursor loops are not the best practice, unless for some unknown reason you 'need' to traipse through a result set row by row.

And, as has been stated before in this newsgroup, Oracle is not SQL Server (and I did not accuse you of thinking it is); it would behoove you to visit the documentatiaon at http://tahiti.oracle.com and peruse the manuals to discover what Oracle can do.

David Fitzjarrell Received on Fri Jun 15 2007 - 12:24:10 CDT

Original text of this message

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