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

From: Michael Moore <michaeljmoore_at_gmail.com>
Date: Thu, 10 Feb 2011 09:24:33 -0800
Message-ID: <AANLkTik0AX9Dudstj0tweG=864FRDez5dF+F49iO6auW_at_mail.gmail.com>



WARNING, OFF TOPIC Howard,

thanks for pointing out my mis-usage of the word 'Practices' . I understand your irritation because I also am a bit of a stickler for using words correctly. The ones that annoy me most are when people use 'less' when they should use 'fewer' and when people use "I" when they should use "me". I could't even break my own kids of misusing these words, so what chance to I have of saving the world? ;-)

Regards,
Mike

On Thu, Feb 10, 2011 at 7:59 AM, Howard Latham <howard.latham_at_gmail.com>wrote:

> Just a little thing - sorry its irritating me The Expression is Best
> Practice not Best Practices.
>
> http://en.wikipedia.org/wiki/Best_practice
>
>
>
>
> On 9 February 2011 21:45, Michael Moore <michaeljmoore_at_gmail.com> wrote:
>
>> I can think of many ways to do this but is there a definitive best
>> practice?
>> I'm sure there must be articles on this somewhere, so links as well as
>> comments are appreciated.
>>
>> BEGIN
>> for cur1 in (SELECT bla bla bla)
>> LOOP
>>
>> If something_I_dont_like then skip to next record in cur1;
>>
>> Lots and lots of code goes here.
>>
>> END LOOP;
>> END;
>>
>> Some options:
>> 1) You could set up a label and use a goto.
>> 2) You could set up an inner block and use RAISE to break out:
>>
>> 3) You could do something like :
>>
>> BEGIN
>> for cur1 in (SELECT bla bla bla)
>> LOOP
>> <<process_this_record>>
>> FOR c2 IN (SELECT * FROM DUAL) -- creates an exitable one-time
>> loop
>> LOOP
>>
>> If something then
>> exit process_this_record;
>>
>> Lots and lots of code goes here.
>>
>> END LOOP process_this_record;
>> END LOOP;
>> END;
>>
>> 4) You could just nest IF statements like:
>>
>> BEGIN
>> for cur1 in (SELECT bla bla bla)
>> LOOP
>> IF keep_processing_this_transaction THEN
>> BEGIN
>> Lots and lots of code goes here.
>> END IF;
>> END LOOP;
>> END;
>>
>> So, what is the best way?
>>
>> Regards,
>> Mike
>>
>
>
>
> --
> Howard A. Latham
>
> Sent from my Nokia N97
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Feb 10 2011 - 11:24:33 CST

Original text of this message