Selecting/Ordering/ROWNUMBER in Oracle 9i

Hello,
I am trying to sort a large table by 'splitting' it in 2 ranges based on the numeric
value of a varchar2 column:
colA=varchar2(7) (represents a numeric range, like a transaction number)
If hypothetically the table has 1000 rows I am trying to split it into 1-500 and 501-1000
then I do:
statement1:
SELECT colA FROM (select rownum AS z,colA from TABLE1 ORDER BY lpad(colA,7) ASC ) WHERE z>=1 and z<501;
statement2:
SELECT colA FROM (select rownum AS z,colA from TABLE1 ORDER BY lpad(colA,7) ASC ) WHERE z>=501 and z<1001;
This is not working: I am finding values of colA in the second statement output that
should be in the first select range based on numeric value
e.g.
Doing MAX(colA) for statement1(lower range) gives 1030240
Doing MIN(colA) for statement 2 (upper range) gives: 1000008
In an ascending sort, the maximum value of colA in statement1 should be LESS than
the minimum value of statement2 using the same sorting criteria.
Why is this not working? It seems the ROWNUMs get jumbled up here...
Does the "inner" select (select rownum AS z,colA from TABLE1 ORDER BY lpad(colA,7) ASC) attribute the ROWNUMs to the ordered set and then lose
the ordering for the outer select?
Any help greatly appreciated...

If you split your table according to lpad(colA,7) - behaves like to_number(ColA)
and then "check" the result by retrieving each range's min(ColA) and max(ColA) - varchar2 type
the "strange" behaviour will not disappear
=========================
ColA  | lpad(ColA,7)
=========================
1     |       1
12    |      12
123   |     123
1234  |    1234
12345 |   12345
23456 |   23456
3456  |    3456
456   |     456
78    |      78
9     |       9
=========================
ColA  | ordered | rownum
=========================
1     |       1 |  1     <= lower range ColA minimum
9     |       9 |  2     <= lower range ColA maximum
12    |      12 |  3        lower range
78    |      78 |  4        lower range
123   |     123 |  5        lower range
456   |     456 |  6        upper range
1234  |    1234 |  7     <= upper range ColA minimum
3456  |    3456 |  8        upper range
12345 |   12345 |  9        upper range
23456 |   23456 | 10     <= upper range ColA maximumRegards
Etbin

Similar Messages

  • Sub-Select SQL query in Oracle BI Answers

    Hi
    What's the proper usage of Sub-Select SQL query in Oracle BI Answers Version Oracle Business Intelligence 10.1.3.2.1?
    I get [SQL_STATE: HY000] [nQSError: 10058] A general error has occured when trying to Sub Select query like:
    itemno = (SELECT MIN(orders.itemno) FROM mydatabase where rownum < 2 order by orders.itemno)

    Maybe the best is to create a new physical and logical object for your sub-select and join this with your current objects.

  • Ordered hints in Oracle:

    There's a fairly popular Ordered Hint example on the web as follows:
    <CODE>
    select /*+ ordered use_nl(bonus) parallel(e, 4) */
    e.ename,
    hiredate,
    b.comm
    from
    emp e,
    bonus b
    where
    e.ename = b.ename
    </CODE>
    I would like to know what the "parallel(e, 4)" clause does. Where does the "4" come from? What is "parallel" here?
    I also have another question: If I have 5 tables--T_OREGON, T_UTAH, T_VIRGINIA, T_TEXAS, and T_OKLAHOMA--lined up in a join right behind a FROM, coming in at row counts of
    T_OREGON: [a lot of rows; a lot more than T_UTAH]
    T_UTAH: [smaller than T_OREGON] 40550 rows
    T_VIRGINIA: 14 rows
    T_TEXAS: 66 rows
    T_OKLAHOMA: 8 rows
    like so:
    ...from T_OREGON or, T_UTAH ut, T_VIRGINIA va, T_TEXAS tx, T_OKLAHOMA ok...
    my question is, if an Ordered hint can be used here, is it that the smallest table (in this case T_OKLAHOMA) gets placed first in the join and the rest of the table ascension in the join doesn't matter? Or is it that T_OKLAHOMA gets placed first in the join, followed by T_VIRGINIA [at 14 rows], followed by T_TEXAS, T_UTAH, and finally T_OREGON?
    Thank you for any help that you can provide.

    It is why my other question involved the table order
    behind a FROM keyword, (when employing an Ordered
    hint).
    Can anybody help with that question? Thanks again.With rule based optimizer order was important.
    With cost based optimizer (optimizer mode one of the all_rows, first_rows, forst_rows_n) order is not important Oracle itself chooses the order how to join tables.
    If you have gathered statistics leave CBO do his work. See more about optimizer here http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/optimops.htm
    And if you have taken this citation out of http://articles.techrepublic.com.com/5100-22_11-1050199.html then there are at least following problems:
    1) article is 4 years old
    2) article doesn't say anything about downsides using this hint e.g. what if your data changes and order is not relevant anymore, quite high possibility that query is changed but hint forgotten to change, maintaining additional level of complexity where Oracle has invested many many resources to assist users enhancing CBO
    3) and there is at least 1 fallacy in this article these sentences are wrong:
    "When Oracle evaluates table join orders, it must consider every possible combination of tables. For example, a six-way table join has 720 (permutations of 6, or 6 * 5 * 4 * 3 * 2 * 1 = 720) possible ways that the tables can be joined together. This permutation issue becomes even more pronounced when you have more than 10 joined tables in a query: For a 15-way table join, there are over one trillion (1,307,674,368,000 to be exact) possible query permutations that must be evaluated."
    (emphasis is mine - Gints)
    CBO abandons each permutation as soon as the cost is higher than the smallest from previous steps. So in reality CBO is much smarter than article tries to explain.
    If you really want to know how CBO works then I can only suggest to get book Cost based oracle fundamentals by Jonathan Lewis.
    Gints Plivna
    http://www.gplivna.eu

  • OM: Multi-select order lines to apply hold

    We are using Standard Oracle Multi-Select order lines (Ctrl or Shift keys) to apply hold and would like to pop-up an alert when any of the selected lines is having an open delivery. Appreciate any suggestions to handle this requirement. Thanks !

    These are good links for the Apply Hold functionalities.
    What we are looking for is to alert users that any of the multi-selected lines is having an open delivery/shipper.
    Need to identify the internal Line_id multi-selected by users for validating if there is an open delivery/shipper.
    Appreciate any advise.

  • Patches 7446163 y 6851110 in order to use Oracle Text from UCM

    Hello, we have Oracle Enterprise Edition 11.2.0.1 on AIX 6.1.0.0 (64 bits). The client want to use Oracle Text from Universal Content Management, he told me about install the patches 7446163 y 6851110 in order to enable Oracle Text from UCM. I reviewed in Metalink but the readme said that those patches are for Oracle 11.1.0.7. That version (11.2.0.1) include already those patches or those are necessary for we can use the funcionality of Oracle Text from Universal Content Management? I reviewed the components installed on database and the Oracle Text is installed and active.
    Thanks for your help.
    Sincerely,
    Ruben Nieto
    DBA

    Hi
    Oracle DB usually would be installed with Oracle Text enabled (the db side) . To use the features for this we need to have OracleText component enabled on UCM which as you mentioned is already installed and enabled on the ucm server .
    If both the above conditions are already met then you would not need to install any further patches.
    Let me know if it is fine on db and ucm .
    Verify that Oracle Text is enabled on db by executing the following query :
    select comp_name, status from dba_registry;
    It should return the the following result : Oracle Text VALID
    To verify if the component for UCM is installed then you would need to check Administration - Configuration for <instance name> - Enabled Components
    Thanks
    Srinath
    Edited by: Srinath Menon on Dec 26, 2010 8:38 PM

  • How to select a substring in oracle up to a more than one specific character

    How to select a substring in oracle up to a more than one specific character
    for ex : 121.051^NP: FAMILY PRACTICE  ( trim the values before ^ )
                121.051^*NP: FAMILY PRACTICE (trim the value before *).
    with below function I can only get rid of ^ , I want both the specific characters ^ and ^* to be removed at the same time.   
    SUBSTR(p.phys_sub_grp_2_desc,INSTR(p.phys_sub_grp_2_desc, '^') +1)

    Another option is to boldly replace 'em:
    SQL> with t as (
      2  select '121.051^NP: FAMILY PRACTICE' str from dual union
      3  select '121.051^*NP: FAMILY PRACTICE' from dual
      4  )
      5  --
      6  -- actuel query:
      7  --
      8  select substr( replace(str, '*')
      9               , instr(replace(str, '*'), '^')+1
    10               ) str
    11  from   t;
    STR
    NP: FAMILY PRACTICE
    NP: FAMILY PRACTICE
    2 rows selected.

  • Is there a way to get the selection order for selectedProperties?

    app.project.activeItem.selectedLayers seems to be ordered by the selection order, but app.project.activeItem.selectedProperties (at least in Shape Layers) seems to be ordered by the stacking order. Is there a way to get the selection order for selectedProperties?
    Thank you!

    Hi,
    i had tried to investigate this a while back and it's really hard to figure out.
    The array seems to be reorganized using various rules:
         At layer level : preserve the user layer selection order,
         Children of indexed groups : propertyIndex ordering,
         Children of named groups : some internal ordering.
    The following is may be more detail than necessary, and given that it is based on observation, not official docs, it is not so reliable, but well, it might still be of interest !!
    Say you have 2 selected properties A, and B, and call [COMMON PARENT] their "greatest common ancestor", that is:
            A = [COMMON PARENT].property(a1).... property(aA);
            B = [COMMON PARENT].property(b1).... ...property(bB);
    with a1 != b1. Then:
    if [COMMON PARENT] = A (ie if A is an ancestor of B), then A comes first.
            For instance: if you select comp.layer(1).mask(1).maskPath, there are 2 selected properties, the mask group and its maskPath: the first is the group and the second the path (the parent comes first).
    if [COMMON PARENT] is the containing composition, ie A is a property inside comp.layer(a1), and B a property inside comp.layer(b1), then A and B are ordered according to the layers selection order.
            This can have some strange side effects. For instance:
                deselect everything
                select comp.layer(2) (and nothing else)
                select comp.layer(1).transform.position
                select comp.layer(2).transform.position
                ===> comp.selectedProperties = [comp.layer(2).transform.position, comp.layer(1).transform.position] even though the first entry was effectively selected after the second...
    if [COMMON PARENT] is an indexed group, A and B are ordered by propertyIndex
            For instance:
                if you select comp.layer(1).mask(2), then comp.layer(1).mask(1), mask(1) appears before mask(2)
    if [COMMON PARENT] is a named group, ... no clue (internal ordering).
            For instance, at propertyDepth 1, it seems that Time Remapping < Effects < Masks < Material Options < Transform, etc, independantly of the selection order, and this is also not the propertyIndex ordering.
            At higher depth, in CS5 the ordering seems to be the propertyIndex ordering, but it is no longer true in CC.
            For instance, selected Position (index 2), Scale (index 6) and Opacity (index 11) in various order on the same layer.
            in CS5 : selectedProperties = [Position, Scale, Opacity];    // propertyIndex ordering, always
            in CC : selectedProperties = [Scale, Position, Opacity];    // always the same ordering, but not the propertyIndex one
    So the ordering is a lexicographic ordering (Compare the ancestor of depth 0. If no difference, compare the ancestor of depth 1. If no diff, compare the ancestor at depth 2. And so forth).
    But at each step, the comparaison depends on the type of the ancestor, and when the type is named group, the ordering is internal so we can't know.
    Practically the most important thing is that selected properties seem to be reorganized by "containing layer" (the layer selection is preserved),
    and then in each layer selected properties are "grouped by same parent": you can't have a mask related property, then an effect related property, then another mask related property:
    all masks related properties appears together, all effect related properties appear together, etc.
    If several effects are selected, effect(1) and all its properties appear first (if selected), then effect(2) and all its properties would appear second etc
    and so forth
    Xavier.

  • Selecting only time in oracle forms

    Hi all,
    like date picker in oracle forms can i select the time in oracle forms into a text item.
    i want to display the time in this format 10:10:30 a.m. and also i want to insert into the table
    i have taken the data type of this column as varchar2(15) if i take date can i insert the time or varchar2 is ok.
    my oracle forms version is 10g.
    please reply...

    Hi, extreme
    extreme wrote:
    Hi all,
    like date picker in oracle forms can i select the time in oracle forms into a text item.
    i want to display the time in this format 10:10:30 a.m. and also i want to insert into the table
    i have taken the data type of this column as varchar2(15) if i take date can i insert the time or varchar2 is ok.Better take column having data type date. You can insert date and time in the date field.
    Just you need to change in forms.
    Change the Data type Date to Datetime
    to show only time, use format mask.
    Hope this helps

  • To add order mgmnt in oracle crm ondemand

    is it possible to add order management in oracle crm ondemand? if it's could u pl tell me the steps involved
    mailid: [email protected]
    Edited by: user9005557 on Jan 19, 2010 4:31 AM

    There are couples of web services provided by oracle for this purpose, by using that you can insert, update, query, delete records in CRM OnDemand.
    So you need to write the web service client program which takes data from your web form and create record in OnDemand. It can be in any language / platform (like java, c++, PHP etc)
    Check web services guide for more details.
    Dinesh

  • IDVD 09:  Scenes page - Chapter select order in wrong order

    I have an iDVD (iLife09) project that contains 35 chapters and have previewed it in DVD Player.
    When using the controller's right advance button, the chapters are not selected in their proper order. Each scene page has a different chapter select order, with none of them being logical or correct. I had edited the video and added the chapters in Final Cut Express and then separately in iMovie. Both have the same results.
    It seems that this has been a long-lived problem, as I recall having the same results with a few earlier versions of iDVD. Unfortunately, if you have a slick video, the Scenes/Chapter selection options makes for a poor presentation.
    Any fixes, suggestions, or reasons why this is an ongoing problem would be greatly appreciated.

    Did you follow these steps?
    http://support.apple.com/kb/TS1611
    http://support.apple.com/downloads/iLifeSupport_9_03
    http://www.mydvdedit.com/index.php?lang=english
    http://www.dvinfo.net/conf/non-linear-editing-mac/127485-quality-fce-imovie-idvd -fc.html
    http://archive.bagelturf.com/canons3/s3fce/index.php
    http://www.simplydv.co.uk/simplyBB/viewtopic.php?f=4&t=20934
    The above are additional tools / links you may find useful but if not just come on back.
    Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software / products that may be mentioned in this topic. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information above at your own discretion.
    Message was edited by: SDMacuser

  • Object selection order.

    I wonder if there's a way to set the selection index as to the real selection order and not the creation order.
    e.g.
    if i create 3 textframes on a page:
    named these as txtFrame1, txtFrame2 and txtFrame3.
    I first select txtFrame3 followed by txtFrame1 and last txtFrame2 and assign them as TEXT tag.
    in InDesign CS2, result will be:
    The sequence in the XML structure will be exactly which I select and tag first.
    which is: content of txtFrame3, then content of txtFrame1 and last content of txtFrame2.
    However in CS3/CS4
    The sequence in the XML structure will be based on the creation of the txtFrames on the page.
    which is: content of txtFrame1, then content of txtFrame2, content of txtFrame3!!!
    Is there a way to have it as what the CS2 way?
    Thanks a million!!!

    I guess with their productivity highly affected,
    adobe may loss more than hundreds of upgrade sales from these group of people.
    to be honest ... I don't think they care ...
    for me - removing this option is inexplicable - I can understand why some options can't be added at beginning - but I can't understand why 100% usefull information is removed in new version of program ... if somebody need to get order of creation - he can collect IDs of all selected objects and sort ... 
    robin
    www.adobescripts.co.uk

  • Billing of pre-selected orders in a specific sequence

    Hi,
      my customer uses manual data entry of sales orders with data he gets from a bunch of papers thus generating a lot of sales orders each day. When the time comes to bill these orders - one bill per order - of different content (customers, billing dates etc.), he selects them using a client specific report - depending on application oriented criteria - and wants them afterwards be billed in a background job / without any further user interaction in the sequence of the order numbers.
    The reason for it is, that he has to check the printed bills with the bunch of paper he used for data entry of the sales orders and he has to add some of these papers to the bills to be sent out via mail afterwards.
    So the sequence of both has to be the same for obvious reasons. The sequence of the bunch of papers is reflected in the sales order numbers, the sequence of the bills in the bill numbers. Bill numbers are generated internally thus depending on the sequence in which the sales orders were billed.
    I tried VF06 giving it sales order numbers to be billed in the proper sequence. But it seems that VF06 sorts these orders first by bill date and/or customers thus destroying the order of sales orders.
    Additionally I tried a couple of VF06 runs, one per sales order. But these runs are computed in parallel thus again destroying my preselected sequence. If I could change the job attributes of such a sequence ob VF06 jobs - one depending on the finishing of the prevoius one, this would solve the problem. But unfortunately the jobs are already "planned" so that I can't add a dependency between them after creation via VF06.  
    Does anyone has a good idea? Additions to my suggestions above? Or fresh and new ideas?
    Thank you very much in advance.
    GeraldS

    Hello Gerald,
    sounds like a quite curios process. 
    The standard transactions (VF04/VF06) are more or less written to deal with mass processing, so i don't think you could influence them the way you need.
    If you need the invoices in the order of the ordernumbers, the only way is to book them one by one using VF01.
    You could use a background job if you write a little own program performing these steps:
    - selecting order-Number to be billed,
    - sorting them
    - calling vf01 for each order via call transaction
      ( with Update option 'S') .
    Make sure that this program can only run  once in the system ( using an lock object).
    As a small solution that could work.
    A bigger (and better) solution would be scanning this 'bunch of paper', connecting the documents to the orders inside SAP.
    Regards Wolfgang

  • Working around the frame selection order issue in CS 4

    Hi guys,
    I'm trying to write a javascript in Indesign that will copy the contents of every selected text frame into the clipboard. The main problem is the selection order, since I'm using CS 4. I'm trying to work around the problem by writing the X and Y coordinates of every frame in arrays through a "for" loop, since the relevant order is always from top left to bottom right in my documents. However, I'm not sure what to do after sorting the arrays : how could I tell the program to use first the frame with the coordinates closest to 0, then the next, etc. ? So far I have this :
    var LesX = new Array();
    var LesY = new Array();
    var Blocs = app.selection;
    for (var i = 0; i < Blocs.length; i++) {
    var myBounds = Blocs[i].geometricBounds;
    var X = myBounds[1];
    var Y = myBounds[0];
    LesX.push(X);
    LesY.push(Y);
    LesX.sort(sortnum);
    Thanks a lot for your help!
    Ma

    Ths is not a good approach. your LesX array will be something like [90, 50, 30, 60, 20] before the sort. And after the sort it will be [20, 30, 50, 60, 90]. But that will not tell you how to find the object whose X value is 20.
    I would write it like this:
    function byYX(a,b) {
        var
            aY = a.geometricBounds[0],
            bY = b.geometricBounds[0],
            aX = a.geometricBounds[1],
            bX = b.geometricBounds[1],
            dy = bY-aY,
            dx = bX-aX;
        return dy?dy:dx;
    var blocs = app.selection;
    blocs.sort(byYX);

  • Order checking via Oracle Wireless

    Dear all;
    I was wondering is it possible to perform order checking thru Oracle 9i Wireless Application. I am currently in a project trying to develop a mobile application that can directly integrate with Oracle 11i E-Business Suite, eg: for order checking, inventory status, credit limit, etc.
    Please help. Would appreciate if u can direct me to where i cane get more technical information regarding this possibilities.
    thank;
    andrew, Malaysia

    Hi,
    Did you change the TNSNAMES.ORA file for DS? you have to add TNS entry to DS TNSNAMES.ORA file.
    Go to $DB_Default_Home$\netword\admin and open TNSNAMES.ORA file in notepad. Copy the tns entry from which you are connecting from SQL*plus.
    Go to $DS_Default_Home$\netword\admin and open TNSNAMES.ORA file in notepad. paste the tns entry you copied.
    Now try to connect from form builder.
    regards,
    Qasim Javaid

  • Prod Orders merge for oracle requirement

    Hi,
    Iu2019m a xi consultant. I need to know about Production Order processing.
    Iu2019ve to send sales orders (with multiple items) from oracle. And I need to get back the
    production orders back to oracle.
    Like:
    Sales order 1 header
    Sales order item1u2026
    Sales order item 2u2026
    Sales order 2 header
    Sales order item1u2026
    Sales order item 2u2026
    u2026.
    As per my understanding, for each sales order item, thereu2019ll be a production order in sap. If this is right, If I use Idoc LOIPRO, Iu2019ll get the individual production orders per every idoc. But I need to send the same way I get the data from Oracle.
    Like:
    Production order 1 header (with ref. to sales order 1 header)
    Production order item1u2026  (with ref. to sales order item 1 header)
    Production order item 2u2026 (with ref. to sales order item 2 header)
    Production order 2 header (with ref. to sales order 2 header)
    Production order item1u2026(with ref. to sales order item 1 header)
    Production order item 2u2026(with ref. to sales order item 2 header)
    u2026
    This is the requirement from customer side.
    Is it possible with standard Idoc LOIPRO?
    If yes, where I need to consolidate(merge) the individual IDocs to a single production order response to oracle?
    Is there any better approach?
    thanks
    zia

    Solved.

Maybe you are looking for

  • New MBP and lost contacts I had.

    I had them on a back-up drive but they are gone from there from that drive and Im PO'd....need to xfer my contact list from iTouch to new computer. is there a way or Im I loosing my mind or both. I thought I could use my iTouch as a backup but when I

  • SOAPFault received from Integration Server. ErrorCode/Category: XIServer/IN

    Hello All, I work on PI 7.1 and needed to create an interface using a simple File-to-File scenario. I created this without using any IR/ESR Objects as per a technical article on the website saptechnical dot com /Tutorials/XI/File2File/Demo1.htm This

  • Steps to create a Network!

    Hello guys! I have a road table... And I created 2 tables: node_topo and link_topo, using scripts from lucvanlinden: Re: Spatial Network constraints Everthing is all right, but I stucked now... What is the next step ? In the end I need calculate the

  • SAP ECC6.0 cannot connect to SQL Server Database after recreating DB server

    We had a disaster with our ECC 6.0 Development system a few days ago.  The system is called “DEV”.  The SQL Server database server got wiped out and we didn’t have a backup.  Luckily, we did have a backup of the database.  Our system engineers rebuil

  • Error when open RSPLAN (Modeler or Wizard)

    When I run RSPLAN (modeler or wizard), I've got the following error: URL http://gowsap21.pratika.br:8000/sap/public/myssocntl call was terminated because the corresponding service is not available. Note: The termination occured system DB2 with error