Is there any point in having an ORDER BY clause within a FOR LOOPs counter?

DB Version:10.2.0.1.0
I need to loop through empno's using a FOR loop. But is there any point in having an Order by clause within SQL as shown below. This only degrades the performance because of the unnecessary sorting by the ORDER BY clause. Right?
begin
FOR i IN (select empno from emp ORDER BY sal ASC) LOOP 
    curr_stat_id := i.empno +p_gennum;
.

First question you should ask to your self is
"Do i need a FOR LOOP. Cant i do it in a straight SQL"
If the answer is NO (Which is not in several cases) then the next question is.
"What is my requirement"
Having an order by in the Select is totally pertained to your requirement. If your requirement
says you should loop through the employee based on there salary for lowest to highest then yes you
need an order by.
So more than performance point of view its requirement point of you. But if you are more concern about
performance you will first ask to your self
"Do i need a FOR LOOP. Cant i do it in a straight SQL"
Thanks,
Karthick.

Similar Messages

  • I'm having problems manipulating array data within a for loop, and extracting the required sub-arrays generated.

    Hi,
    I'm using labVIEW V5.1
    I'm trying to generate 10 1D arrays, the first array is initialized to all zeroes, then I have set up a for loop which shifts the first element by 1, then a random number is placed into the first element position. I am using a shift register to feed back in the newly generated array into the start of the loop.
    By the end of the each loop I want to be able to use the array generated in an algorithm outside the loop. However I only want the Nx1 array that has just been generated.
    Unfortunately, I cannot figure out how to resize, reshape or index the output array to do this.
    I would like the loop to
    give me out a 1D array after each iteration.
    Any help would be greatly appreciated.

    I hope I've understood your problem.
    First your vi was lacking of the sub-vi working as shift register, I've replaced it with the rotate function.
    The indexing of your arrays create a 2D array whose rows are your 1D array.To pick only one of them you have to use the index array function and select which one you want.
    To use your temporary data in another part of your application you should use a local variable of array2.
    I did it in a separated while loop That I syncronized with the for loop using occurrence, in this way the while loop runs each time a new value is inserted in array2 (each loop of the for loop structure).
    If you don't need this syncronization just get rid of occurrence functions.
    I place a delay in the for loop to show what happens when running.
    Hope it was helpful.
    Alberto Locatelli
    Attachments:
    array_test_v3.vi ‏35 KB

  • Hello, is there any way of having a reboot disk for lion that I'm downloading, like the one I have with snow leopard ?

    Hello, is there any way of having a reboot disk for lion that I'm downloading, like the one I have with snow leopard ?

    Once the Lion download is complete quit the installer and follow these directions. The file you need to make a boot disk disappears after you install Lion.
    Egg Freckles | Burning A Lion Boot Disc
    However, the Lion installation includes a recovery partition. It won't be of help if your entire HD dies but is very handy otherwise. This Knowledge Base article has a lot of good information about Lion's recovery partition.
    OS X Lion: About Lion Recovery

  • Is there any point in a G4 render farm?

    Hi all.
    I've been getting quite intrested in the idea of setting up a very small render farm laterly as I have the option of getting some old G4s for free.
    I currently have a 2.0Ghz DP G5 as my main mac running FCP2 and Shake and was already grabbing a G4 466 digital audio to set up as a file/print and back up server running tiger server, a postscript RIP and retrospect. I have the possibility of getting atleast one more G4 466 DA and maybe a couple of G4 400 AGPs with Gigbit ethernet cards. As the main use would be farming out DV to mpg2 compression via compressor and shake renders (though not large shake stuff to begin with as very new to this) is there any point in looking into this or am I going to need to lots of G4s to make a real improvement in render times.
    Also is RAM a major consideration. For example if I got 4 G4s with say 512Mb ram would it be better runing all four or using three but nicking the fours ram to give more ram in the three machine set up?
    Any advice would be appreciated
    Cheers
    Steve

    I vote no. G4 isn't the problem so much as 400mhz is. The ram shouldn't be a problem.
    But you could test if you set up Compressor on one G4. Compress a job. Compress the same job with the same settings on the G5.
    If the G5 is 4 times (or even 3, since time is spent sending the render data over the network between the G4's slow system busses) as fast the single G4, a render farm will not help you.
    Using the G4 and G5 together in the same cluster does not work because Compressor looks at all processors and divides the job into twice as many segments. In this case, the G5 finishes it's two segments years before the G4's and then sits around waiting. You could try splitting the G5 into 4 instances, but then you have 8 slow processors attacking your job. Not very efficient.
    Good luck though. You should test the one G4 just so you know. Report back if you do.

  • Is there any way to force iPhoto to present faces by folder for identification rather than randomly?  Would provide better context for identification especially if a huge number of images is involved.

    Before I commit the time and energy required to load and tag faces in 25,000 images within iPhoto, I need some questions answered;
    Is there any way to force iPhoto to present faces by folder for tagging rather than randomly?  When so many images need tagging, over many years, the context of a folder helps with the identification. The work around is to load the images into iPhoto one folder at a time and do the tagging then.
    How do I get iPhoto to present the tagged faces by last name rather than first name? When so many faces will be identified, it is much easier to find people by surname, particularly when I share the library within the family. The work around is to enter names as last name and first name.  Being able to toggle the sort is much more desireable.
    Is there a way to export a portion of the library including faces?  I want to pass on portions of this huge 125 GB library to my family members.
    Since my family members will need an Apple computer to view the images and faces, they will likely have their own photo library.  So is there any way to combine two libraries and merge the faces?
    About 2/3 of my images have been scanned, so the date of creation is the scanned date rather than the date the photo was taken.  Will this mess up any sequencing or the retrieval of faces?

    If I want to carve off part of a library, I presume the way to do this is to make a copy of the library using PLM then go into iPhoto and delete what I don't want.  The result is the carved off portion.
    You don't need Library Manager to delete the portion you don't want.
    As a general rule: when deleting photos do them in batches of about 100 at a time. iPhoto can baulk at trashing large numbers at one go.
    If I want to merge two libraries, PLM implies that it will do this but will the Faces be merged too?
    I believe so.

  • Is there any object in labview that contains a list of data for the user to select (selection one at a time) or add a new data?

    Is there any object in labview that contains a list of data for the user to select (selection one at a time) or add a new data?

    List and table controls -> listbox..is that what you are thinking of?
    The listbox presents the user with a list of options, and you can set it to only accept one selection at a time...Adding new data to the list can not be done directly by the user but if you make e.g. a text control and a button you can programatically insert new objects described in the text box when the button is pressed...(see example).
    If you need more than one column you have the multicolumn listbox. If you want the users to write new entries directly yu can use a table and read selected cells using it's selection start property to read what cell has been selected.
    MTO
    Attachments:
    Listbox_example.vi ‏34 KB

  • Is there any way to have a COMPLETE list of all samples and loops ( Logic 8

    I'm sure it's been posted previously, but anyway, I'm looking to buy new Apple Loops libraries and I have faced the fact , that many of the sounds and loops produced by third parties manufacturers have been already included in Logic installation discs.
    I have a list of Apple Loops DVD's that have been included with Logic somewhere, the problem is, Apple didn't post ( I believe) the credits of all 3rd party manufacturers that have produced these libraries that are included with Logic or Garage band. Is there any way to have a COMPLETE list of all samples and loops that are included with Apple DAW's so I wouldn't duplicate anything ? I'm pretty much positive that Apple had other companies to sound design and sample all libraries for them, so is there also a way to have a list of those manufacturers? Again, the objection is to start upgrading the sound library without any possible duplication?
    Thanks in advance!

    Chris, I certainly don't mind additional questions and postings.
    I believe there are many issues with Apple Loops and Logic that need to be resolved and people need to be aware of that. Unfortunately, in opposite to the old "german" version of Logic , there's no lifetime tech support, you can't even call and ask the question after 60 days , which isn't right for a professional software of this level, especially considering the fact that many things still remain vague in Logic even for developers and tech support people!( believe me, I've called and asked!)
    Issues like that need to be resolved over the phone with the company, period!
    One thing I also learned over the years as a Mac OSX user, if something doesn't work, don't mess with it. Delete your drive and re-install everything. This is very frustrating , I know, but unfortunately this is the only way to deal with OSX issues, if you got a problem with your system, don't try to fix it. It's never gonna be the same again. I know , it's off the topic a little bit, but if your content is missing from the system files, before installing your new Logic, back up your important files, wipe up your drive and clean install Mac OSX , run updates and then install the Logic. Most likely , everything will be in it's place, at least 90% or more. I gave up trying to make two system in my house to be compatible 100% , but it's OK if they're 90% or more identical. I spent enormous amount of time trying to find out what's missing and where, I visited most of the forums and there's no clean answer.
    Message was edited by: Moderator

  • Are there any ways to get sequence number other than getting it for each re

    are there any ways to get sequence number other than getting it for each record

    CACHE is the number of values Oracle stores in memory. So the first call to NEXTVAL Oracle grabs x numbers; subsequent calls to NEXTVAL are served from memory until they're all gone and them another bunch is grabbed. The attached sql*plus output demonstrates this behaviour.
    Note that normally unused numbers in the cache are returned to the data dictionary but in exceptional circumstances (DB crash) they may be lost.
    Cheers, APC
    SQL> create sequence seq cache 3
      2  /
    Sequence created.
    SQL> select last_number from user_sequences
      2  where sequence_name = 'SEQ'
      3  /
    LAST_NUMBER
              1
    SQL> select seq.nextval from dual
      2  /
       NEXTVAL
             1
    SQL> select last_number from user_sequences
      2  where sequence_name = 'SEQ'
      3  /
    LAST_NUMBER
              4
    SQL> select seq.nextval from dual
      2  /
       NEXTVAL
             2
    SQL> select last_number from user_sequences
      2  where sequence_name = 'SEQ'
      3  /
    LAST_NUMBER
              4
    SQL> select seq.nextval from dual
      2  /
       NEXTVAL
             3
    SQL> select last_number from user_sequences
      2  where sequence_name = 'SEQ'
      3  /
    LAST_NUMBER
              4
    SQL> select seq.nextval from dual
      2  /
       NEXTVAL
             4
    SQL> select last_number from user_sequences
      2  where sequence_name = 'SEQ'
      3  /
    LAST_NUMBER
              7
    SQL>

  • Are there any good third party or otherwise apps and/or plugins for imovie'11?

    Are there any good third party or otherwise apps and/or plugins for imovie'11?

    Re: Plugins for iMovie 11
    Someone just asked this question yesterday. So I am cutting and pasting the answer From Bengt Warleby
    Hi
    You can not.
    Nor to iMovie'08 or 09 or 11 - They do not accept any Plug-ins.
    How about FinalCut Pro X - I don't know but i regard to Apple way of progress - I doubt
    For iMovie up to HD6 and FinalCut Express and FinalCut Pro up to 7.0 - there are plenty.
    Yours Bengt W

  • Is there any way to disable right click and drag and drop for photos on iweb?

    Re: protecting photos when using iweb as your web designer...
    Is there any way to disable right click and drag and drop for photos using iweb?  I have seen tutorials about creating a text box around each image - but is there a better way? 

    However, there is no way you can prevent someone from making a screenshot of the image as it is displayed on the screen no matter what application you use to create the web page.
    You can add a watermark to dissuade the casual "thief" but those who are serious about stealing the photo for their own use can remove the watermark with some effort.
    OT

  • Is there any way to remove profile names on the itunes wifisync for iphone4?

    is there any way to remove profile names on the itunes wifisync for iphone4?

    selenafrommelbourne wrote:
    a little dumb at times so please forgive me
    do u mean the better halfs phone ... restore his phone on itunes and then set up a new account for him 
    since that (plus one other minor incident) has happened he will not let me touch his phone, so if i can be detailed from experienced people, then he may feel confident and let me do this 
    sounds like a nice guy! if he won't let you touch his phone this may work out better for you...tell him to handle the problem himself.

  • IS IT POSSIBLE TO  WRITE ORDER BY CLAUSE WITHIN INNER QUERY

    IS IT POSSIBLE TO WRITE ORDER BY CLAUSE WITHIN INNER QUERY

    So you still can't :) I still don't see it that strict:
    You know of course that this is possible:
    select ename, (select ename
                     from (select   empno, ename
                               from emp
                              where deptno = 10
                           order by 1) e2
                    where e.empno = e2.empno) a
      from emp eso we have an »ORDER BY CLAUSE WITHIN INNER QUERY« which is even correlated (though through the outer query).
    Whether this makes sense or not is not question imho :-) ... but you can

  • My wife an i have separate Apple id - our iMac iTunes is set up with my Apple id. When i try sinc her iPhone I sign in with her Apple id but it does not show her apps but mine still. Is there any way of having two Apple id on one computer iTunes

    My wife an I have different Apple ID and when I want to sync our other Apple devices it will not accept her Apple ID.
    I sign out and sign in with her Apple ID and i still see all of my apps and music and not hers.
    Is there any way of being able to sync two diffrent Apple ID on the same computer

    Hi RichardR75,
    If you are having issues using multiple devices with one computer, you may find the following article helpful:
    Apple Support: How to use multiple iPhone, iPad, or iPod devices with one computer
    http://support.apple.com/kb/HT1495
    Regards,
    - Brenden

  • Is there any performance difference in the order of columns referencing index?

    I wish to find out if there is any performance difference or efficiency in specifying those columns referencing index(es) first in the WHERE clause of SQL statements. That is, whether the order of columns referencing the index is important???.
    E.g. id is the column that is indexed
    SELECT * FROM a where a.id='1' and a.name='John';
    SELECT * FROM a where a.name='John' and a.id='1';
    Is there any differences in terms of efficiency of the 2 statements??
    Please advise. Thanks.

    There is no difference between the two statements under either the RBO or the CBO.
    sql>create table a as select * from all_objects;
    Table created.
    sql>create index a_index on a(object_id);
    Index created.
    sql>analyze table a compute statistics;
    Table analyzed.
    sql>select count(*)
      2    from a
      3   where object_id = 1
      4     and object_name = 'x';
    COUNT(*)
            0
    1 row selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=29)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=1 Card=1 Bytes=29)
       3    2       INDEX (RANGE SCAN) OF 'A_INDEX' (NON-UNIQUE) (Cost=1 Card=1)
    sql>select count(*)
      2    from a
      3   where object_name = 'x'   
      4     and object_id = 1;
    COUNT(*)
            0
    1 row selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=29)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=1 Card=1 Bytes=29)
       3    2       INDEX (RANGE SCAN) OF 'A_INDEX' (NON-UNIQUE) (Cost=1 Card=1)

  • Is there any user exit/ badi to populate the partner bank type for   F-63.

    Is there any user exit/ badi to populate the partner bank type (field name BSEG-BVTYP) in transaction F-63. There is exit ‘ZFI_FOAP_CDITEMS_00001011’ having BKPF and BSEG as only import parameters so I can’t change the value for BSEG-BVTYP.
    So could you please let me know any exit where I can change the value for BSEG-BVTYP for transaction F-63?
    Thanks in Advance,
    Steevan

    hi,
    Below r the user exit related to transaction  F-63.
    Check out if any of them will solve ur Query..
    F050S001            FIDCMT, FIDCC1, FIDCC2: Edit user-defined IDoc segment
    F050S002            FIDCC1: Change IDoc/do not send
    F050S003            FIDCC2: Change IDoc/do not send
    F050S004            FIDCMT, FIDCC1, FIDCC2: Change outbound IDoc/do not send
    F050S005            FIDCMT, FIDCC1, FIDCC2 Inbound IDoc: Change FI document
    F050S006            FI Outgoing IDoc: Reset Clearing in FI Document
    F050S007            FIDCCH Outbound: Influence on IDoc for Document Change
    F180A001            Balance Sheet Adjustment
    FARC0002            Additional Checks for Archiving MM Vendor Master Data
    FEDI0001            Function Exits for EDI in FI
    RFAVIS01            Customer Exit for Changing Payment Advice Segment Text
    RFEPOS00            Line item display: Checking of selection conditions
    RFKORIEX            Automatic correspondence
    SAPLF051            Workflow for FI (pre-capture, release for payment)
    Reward points if helpful,
    Regards,
    Brijesh

Maybe you are looking for