Start with Connect By: What if Parent is the Child?

Version : 11g
Hi There,
I had a question regarding Start with Connect by.
The following is an example from the ORacle help from the Emploees table
select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
       level,
       First_name as title,
       NULL  as icon,
       EMPloyee_id as value,
       First_name as tooltip,
       NULL  as link
from EMPLOYEES
start with Manager_id ='171'
connect by prior EMPLOYEE_ID = Manager_id
order siblings by First_nameNow this works fine and shows the levels. In the help the start with is actually
start with Manager_id is nullNow if we use a lowest level employee using something like
start with Manager_id = '171'no rows are returned. This is because there are no child records for this employee (he is not a manager).
However, is it possible to atleast show this one record as the output? Any suggestions?
Thanks,
Ryan
Edited by: ryansun on Dec 10, 2012 10:51 PM

One way
start with
  ( manager_id ='171'
    or
       employee_id='171'
       and '171' not in (
                         select distinct manager_id
                         from employees
                         where manager_id is not null
  )Edited by: jeneesh on Dec 11, 2012 12:35 PM

Similar Messages

  • Start With/Connect by

    DB is 11gR1
    I have a table that defines formulas for items that are created (line_type = 1) and what ingredients are needed to make it (line_type = -1). Some ingredients also need to be made, so they will have another record in the table (different formula) with a line_type of 1, and the ingredients that make it up. Those ingredients could also be created, and so on.
    So in the example below formula 807 creates item 4112949142. The line_type = -1 for formula 807 define the ingredients that make up that item. One of the ingredients, KT00518, is also a manufactured item, defined by that item with line_type = 1 which is formula 1420. Ingredient WP50255 is manufactured with formula 3030.
    What I need to be able to do, is starting with formula 807, recursively loop through all the formulas to get all of the ingredients needed to make that item:
    KT00518
    PK15199
    PK13947
    RM31009
    RM30711
    RM31004
    WP50255
    RM30951
    RM30948
    RM30981
    RM30957
    In this simple case it would be easy because there are no formulas that are not related to this item, but obviously I need a way to do this with a start with/connect by in the real world:
    SELECT *
      FROM XX_FORMULA
    WHERE line_type = -1
    DROP TABLE XX_FORMULA;
    CREATE TABLE XX_FORMULA
      FORMULA_ID     NUMBER          NOT NULL,
      ITEM           VARCHAR2(60)    NOT NULL,
      LINE_TYPE      NUMBER          NOT NULL,
      LINE_NO        NUMBER          NOT NULL
    --Top Level
    INSERT INTO XX_FORMULA
    VALUES( 807,'4112949142',1, 1);
    INSERT INTO XX_FORMULA
    VALUES( 807,'KT00518',-1, 1);
    INSERT INTO XX_FORMULA
    VALUES( 807,'PK15199',-1, 2);
    INSERT INTO XX_FORMULA
    VALUES( 807,'PK13947',-1, 3);
    --Middle
    INSERT INTO XX_FORMULA
    VALUES( 1420,'KT00518',1, 1);
    INSERT INTO XX_FORMULA
    VALUES( 1420,'RM31009',-1, 1);
    INSERT INTO XX_FORMULA
    VALUES( 1420,'RM30711',-1, 2);
    INSERT INTO XX_FORMULA
    VALUES( 1420,'RM31004',-1, 3);
    INSERT INTO XX_FORMULA
    VALUES( 1420,'WP50255',-1, 4);
    --Leaf
    INSERT INTO XX_FORMULA
    VALUES( 3030,'WP50255',1, 1);
    INSERT INTO XX_FORMULA
    VALUES( 3030,'RM30951',-1, 1);
    INSERT INTO XX_FORMULA
    VALUES( 3030,'RM30948',-1, 2);
    INSERT INTO XX_FORMULA
    VALUES( 3030,'RM30981',-1, 3);
    INSERT INTO XX_FORMULA
    VALUES( 3030,'RM30957',-1, 4);Thanks in advance for your help.
    --Johnnie                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi,
    Vortex13 wrote:
    DB is 11gR1
    I have a table that defines formulas for items that are created (line_type = 1) and what ingredients are needed to make it (line_type = -1). Some ingredients also need to be made, so they will have another record in the table (different formula) with a line_type of 1, and the ingredients that make it up. Those ingredients could also be created, and so on.
    So in the example below formula 807 creates item 4112949142. The line_type = -1 for formula 807 define the ingredients that make up that item. One of the ingredients, KT00518, is also a manufactured item, defined by that item with line_type = 1 which is formula 1420. Ingredient WP50255 is manufactured with formula 3030.Okay, so that explains that
    VALUES( 807,'KT00518',-1, 1);is the parent of
    VALUES( 1420,'KT00518',1, 1);But it looks like there's also another kind of parent-child relationship in this table. That is, the last row I showed above apparantly has children. I'm guessing that
    VALUES( 1420,'RM31009',-1, 1);is one of its children. That is, a row with line_type=1 can have children: any row with the same formula_id and line_type=-1 is its child. Is that right?
    If so:
    SELECT     *
    FROM     xx_formula
    WHERE     line_type     = -1     
    START WITH     formula_id     IN (807)     -- Change as needed
          AND     line_no          = 1
    CONNECT BY     (    item          = PRIOR item
              AND  line_type          = 1
              AND  PRIOR line_type     = -1
         OR     (    formula_id          = PRIOR formula_id
              AND  line_no          = PRIOR line_no + 1
    What I need to be able to do, is starting with formula 807, recursively loop through all the formulas to get all of the ingredients needed to make that item:
    KT00518
    PK15199
    PK13947
    RM31009
    RM30711
    RM31004
    WP50255
    RM30951
    RM30948
    RM30981
    RM30957I get 20 rows of output, not just the 11 you want. I guess I don't understand the requirements.
    Here are my results:
    FORMULA_ID ITEM        LINE_TYPE    LINE_NO
           807 KT00518            -1          1
          1420 RM31009            -1          1
          1420 RM30711            -1          2
          1420 RM31004            -1          3
          1420 WP50255            -1          4
          3030 RM30951            -1          1
          3030 RM30948            -1          2
          3030 RM30981            -1          3
          3030 RM30957            -1          4
           807 PK15199            -1          2
           807 PK13947            -1          3
           807 KT00518            -1          1
          1420 RM31009            -1          1
          1420 RM30711            -1          2
          1420 RM31004            -1          3
          1420 WP50255            -1          4
          3030 RM30951            -1          1
          3030 RM30948            -1          2
          3030 RM30981            -1          3
          3030 RM30957            -1          4Take a couple of examples where I'm getting the wrong results, and explain again, using different words, how you get the right results in those places.
    Maybe I just need to say SELECT DISTINCT .
    In this simple case it would be easy because there are no formulas that are not related to this item, Yes, it would be better to add a couple of rows that are not related. Why don't you?
    but obviously I need a way to do this with a start with/connect by in the real world:Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.

  • Start with Connect by: Showing the whole hierarchy even if child parameter

    11g
    Hi There,
    In our case the manager_id i= employee_id for the top level manager. So when I run the sql, it eliminates the top level manager and shows the output for the next level onwards.
    For the regular start with connect by option on the employee table the query used is
    select case when connect_by_isleaf = 1 then 0 when level = 1 then 1 else -1 end as status,
           level,
           First_name as title,
           NULL  as icon,
           EMPloyee_id as value,
           First_name as tooltip,
           NULL  as link
    from EMPLOYEES
    start with Manager_id is null
    connect by prior EMPLOYEE_ID = Manager_id
    order siblings by First_namenow this will show the hierarchy and level starting with managers. Now if we provide the "start with Manager_id = 171" then since 171 is not a manager no rows are returned. So for this we can use something like
    start with manager_id =171 or employee_id = 171However, the output would be only the employee record since 171 is the last child.
    The requirement we had was that, Irrespective of the value entered, whether ultimate parent or ultimate child the output should still show the top down hierarchy. starting with that persons ultimate manager.
    So for example if there are two employees, 170 and 171 and 170 is the manager of 171
    If in this query I use Start with manager = 170. It will show me the manager and the child records.
    However, if I use start with manager = 171 or employee_id = 171 then it will only show me only the child record. I want it to show me both the manager and employee records. i.e all the levels
    I hope that make sense!
    Thanks,
    Ryan
    Edited by: ryansun on Dec 12, 2012 1:13 AM
    Edited by: ryansun on Dec 13, 2012 1:59 AM

    Hi Alberto,
    I was using this query and the output is correct. Except for one thing, the nature of our data is such that the top most manager in this case has "Manager_Id" as null so we can use "start with Manager is null"
    But in our case the manager id for the top most manager is the same as his employee id.
    So If I modify the query, it then does not show the "top most managers record"
    WITH entire_tree AS
        SELECT *
          FROM employees
         START WITH manager_id = 171
       CONNECT BY PRIOR employee_id = manager_id
       UNION
        SELECT *
          FROM employees
         START WITH employee_id = 171
       CONNECT BY employee_id = PRIOR manager_id
    SELECT CASE WHEN CONNECT_BY_ISLEAF = 1 THEN 0 WHEN LEVEL = 1 THEN 1 ELSE -1 END AS status
          , LEVEL
          , first_name AS title
          , NULL AS icon
          , employee_id AS VALUE
          , first_name AS tooltip
          , NULL AS link
       FROM entire_tree
      START WITH manager_id = 100
    CONNECT BY PRIOR employee_id = manager_id
      ORDER SIBLINGS BY first_name;the only change I made is from
    Start with manager_id is null
    to
    start with manager_id = 100Basically, in this case the manager_id of the top most manager is the same as his employee id. So how can we have that condition incorporated instead of checking for null.
    Thanks,
    Ryan

  • Hi, Im from Philippines,.... i am currently using my iPhone 4 (iOs.6.3)it  started when i upgrade it from iOs4 to iOs 6.3 , My iPhone doesnt identify numbers even if its in my contact if its not starting with  +63 ..what will i do?

    Hi, Im from Philippines,.... i am currently using my iPhone 4 (iOs.6.3)it  started when i upgrade it from iOs4 to iOs 6.3 , My iPhone doesnt identify numbers even if its in my contact if its not starting with  +63 ..what will i do?
    I change everything into +63 and i thought everything is already fine,.. and then now , i dont know what happened why it doesnt recognize numbers with +63 anymore

    Hello hsielglad,
    Thank you for your question. iTunes 11.1 is required to update to and sync with iOS 7.  If you are still running iTunes 10.6.3, I recommend trying to obtain the update by going to the iTunes menu and selecting Check for Updates.
    iTunes: How to install the latest version
    http://support.apple.com/kb/HT5654
    If you continue to get the message that iTunes is up to date, you can download the latest version of iTunes here:
    Download iTunes
    http://www.apple.com/itunes/download/
    Once the file downloads, double click on the installation file that downloaded to initiate the installation.
    Best,
    Sheila M.

  • Building a recursive query using start with/connect by......

    Hi.
    I have data in a table which looks like:
    Top level     Step     3rd Level     4th Level Script Name
    NORMAL_DAY     Step 1 of NORMAL_DAY     DATE_FEEDER     Step 1 of DATE_FEEDER      INT_EOD_DATE_FEEDER
    NORMAL_DAY     Step 2 of NORMAL_DAY     EOD_FX_RATE_UPLOAD Step 3 of EOD_FX_RATE_UPLOAD SEND_MAIL_FXSPOTS
    NORMAL_DAY     Step 2 of NORMAL_DAY     EOD_FX_RATE_UPLOAD Step 2 of EOD_FX_RATE_UPLOAD FXSPOTS
    NORMAL_DAY     Step 2 of NORMAL_DAY     EOD_FX_RATE_UPLOAD Step 1 of EOD_FX_RATE_UPLOAD FX_FTPS_GET_EOD
    NORMAL_DAY     Step 3 of NORMAL_DAY     CALENDAR_UPLOAD     Step 1 of CALENDAR_UPLOAD     CALENDAR
    NORMAL_DAY     Step 3 of NORMAL_DAY     CALENDAR_UPLOAD      Step 2 of CALENDAR_UPLOAD     MDS_STOP
    NORMAL_DAY     Step 3 of NORMAL_DAY     CALENDAR_UPLOAD     Step 3 of CALENDAR_UPLOAD     MDS_HOLIDAY
    NORMAL_DAY     Step 3 of NORMAL_DAY     CALENDAR_UPLOAD     Step 4 of CALENDAR_UPLOAD     MDS_START
    NORMAL_DAY     Step 4 of NORMAL_DAY     FA_VALUATIONS     Step 1 of FA_VALUATIONS     IMPORTMTM
    NORMAL_DAY     Step 4 of NORMAL_DAY     FA_VALUATIONS     Step 2 of FA_VALUATIONS     INT_EOD_VALUATIONS
    As you can see, it lends itself to a tree type structure. I am trying to display this information using the start with/connect by clauses.....
    My initial query looks like:
    select main.name "Top Level",
    level2.name "Step",
    level3.name "3rd Level",
    level4.name "4th Level",
    level5.name "Script Name",
    level5.run_start,
    level5.run_end,
    (level5.run_end - level5.run_start) "Time difference",
    to_char((level5.run_end - level5.run_start),'99999999999999999999999999990.0000000000')*1000 as Total_Run_Time
    from jcs_jobs main,
    jcs_jobs level2,
    jcs_jobs level3,
    jcs_jobs level4,
    jcs_jobs level5
    where main.name = 'NORMAL_DAY'
    and main.PARENT_JOB_ID IS NULL
    and main.job_id = 2253800
    and main.job_id = level2.parent_job_id
    and level2.job_id = level3.parent_job_id
    and level3.job_id = level4.parent_job_id
    and level4.job_id = level5.parent_job_id
    order by level2.step_name;
    This is a bit restrictive, so I need to make it more generic, because we can actually have more than 5 levels of depth.....
    I haven't included the time element in the sample data. This also appears to be another conundrum.....how to display milliseconds in a reasonable date format?
    Thank you very much in advance!
    Dev

    try this way:
    SQL> select script_name, job,
      2         to_char(to_date(run_start,'Jhh24miss'),'dd-mon-yyyy hh24:mi:ss') run_start,
      3         to_char(to_date(run_end,'Jhh24miss'),'dd-mon-yyyy hh24:mi:ss') run_end,
      4         (to_date(run_end,'Jhh24miss')
      5                  - to_date(
      6                        substr(root_start,
      7                               2,
      8                               decode(instr(root_start,'/',1,2),
      9                                      0,
    10                                      length(root_start)+1,
    11                                      instr(root_start,'/',1,2)
    12                                      )-2
    13                               )
    14                            ,'Jhh24miss')
    15          ) "Time difference"
    16  from (
    17  select name script_name, lpad(' ',2*level,' ')||job_id job
    18         ,to_char(run_start,'Jhh24miss') run_start, to_char(run_end,'Jhh24miss') run_end,
    19         sys_connect_by_path(to_char(run_start,'Jhh24miss'),'/') root_start
    20  from jcs_jobs
    21  where name = 'NORMAL_DAY'
    22  connect by prior job_id = parent_job_id
    23  start with PARENT_JOB_ID IS NULL and job_id = 2253800
    24  );
    SCRIPT_NAM JOB                  RUN_START            RUN_END              Time difference
    NORMAL_DAY   2253800            23-jan-2010 15:30:16 27-jan-2010 01:06:16             3,4
    NORMAL_DAY     2253801          27-jan-2010 01:06:16 28-jan-2010 15:30:16               5Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/23/la-forza-del-foglio-di-calcolo-in-una-query-la-clausola-model/]

  • I can't update my iOS 5! it downloads it and than say that there is error with connection? what should I do?

    it downloads it and than say that there is error with connection? what should I do?

    Are you getting a network connection error or a different error ? If it is a network connection and you've tried turning off all your firewall and antivirus software then you could try downloading the update via a browser : https://discussions.apple.com/message/16703914#16703914

  • I am walking through Apples tutorial getting started with iOS development. I am at the storyboard area and can't seem to drag the cancel button to the green exit. I am not sure why the exit button doesn't except it. Is anyone else having this issue?

    I am walking through Apples tutorial getting started with iOS development. I am at the storyboard area and can't seem to drag the cancel button to the green exit. I am not sure why the exit button doesn't except it. Is anyone else having this issue? Is there a work around? I have done this app twice and still cant get the exit to except the Cancel or Done  bar buttons

    Yes I checked it.  As far as I can see I did everything Apple said to do.  I took some screen shot so you can see how the screens are connected and what and where the code is, and what it does when I drag the cancel and done bar buttons to the exit

  • TS4006 My phone will not turn on, therefore I have received a replacement phone but am wanting to reset my old device. It is not locating it because it says it is offline however I cannot turn it on at all. Can I start with my new device and not reset the

    My phone will not turn on, therefore I have received a replacement phone but am wanting to reset my old device. It is not locating it because it says it is offline however I cannot turn it on at all. Can I start with my new device and not reset the old? Any help would be greatly appreciated. It's been a week without a phone

    That does happen.  It depends on how hard the server is being hit, as well as the connection speed of your system.  If you are on a windows system, you will want to disable any antivirus or firewall software during the download.

  • Creating a template in Pages is straight-forward as answered here previously. Is there and equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template?

    Creating a template in Pages is straight-forward as answered here previously. Is there an equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template? This has proved unsatisfactory to me so far. Lines are left in etc.

    There are two basic menus for fonts - one from the main menu bar and one from the toolbar. You can also bring up the font manage dialog.
    I don't recommend trying to hard to force an otherwise foreign font, as it inevitably needs to be usable/supported on iOS as well, and that can get tricky w/3rd party fonts, as an example, even with the expanded font support in the latest iBA.
    If you need to discuss fonts more, I suggest starting a new thread....preferably with a slightly more brief title, thanks.

  • Hierarchy/heirarchical queries/query start with connect

    ok... I have seen many examples of using hierachical queries. All of the example has parent as null and children with 1 parent. I haven't seen any query that queries a child with multiple parents.
    For example.
    Table A:
    Child--Parent
    1--null
    2--1
    3--1
    3--2
    4--3
    5--2
    Select query:
    Select child, level
    from A
    start with child = 3
    connect by prior child = parent
    Result
    Child--Level
    3--1
    4--2
    3--1
    4--2
    Notice that it display the child '3' twice. Its because it has 2 different parent.
    My question is that, how do I make the query to display this iteration once?

    Hi, Sentinel,
    I'd love to see a solution that simple, but I don't think it's possible.
    Suppose you want to see child=2 and all it's descendants:
    --<"begin sample data">
    with a as (select 1 child, null parent from dual
    union all select 2, 1 from dual
    union all select 3, 1 from dual
    union all select 3, 2 from dual
    union all select 4, 3 from dual
    union all select 5, 2 from dual
    --<"cut here">
    Select child, level
       from (select child, min(parent) parent from a group by child)
      start with child = 2
    connect by prior child = parent;Produces this output:
         CHILD      LEVEL
             2          1
             5          2I believe OP wants to get this for the descendants of child=2:
         CHILD      LEVEL
             2          1
             5          2[b]
             3          2
             4          3So what happened to child=3? For child=3, MIN (parent) = 1, according to this query. That's true when the universe is the entire table, but we're only interested in child=2 and its descendants.
    Message was edited by:
    Frank Kulash
    By the way, the comments
    --<"begin sample data">
    and
    --<"cut here">
    are brilliant!

  • How to pass multiple parameters to Query using START WITH, CONNECT BY OBIEE

    Hi
    I have following oracle query which need to be used as a Data Source in OBIEE Physical Layer. I guess I have to create stored proc. How do I implement this in OBIEE RPD and how do I implement the respective Dashboard prompts for the parameters.
    SELECT
    CIRC.PATH_NAME, CIRC.BANDWIDTH , CIRC.CATEGORY, CIRC.CUSTOMER_ID,
    CIRC.STATUS, CIRC.CUSTOMER_NAME,
    QUER.LEV
    FROM
    CIRCUIT_PATH circ, VAL_CUSTOMER cust,
    ( SELECT
    DISTINCT CIRC_PATH_INST_ID, LEVEL LEV
    FROM
    CIRC_PATH_ELEMENT
    START WITH
    CIRC_PATH_ELEMENT.CIRC_PATH_INST_ID IN ( SELECT
    DISTINCT CIRC_PATH_INST_ID
    FROM
    PORTS a
    WHERE SITE_NAME = @variable('Enter a Site Name')
    AND CARD_SLOT = @variable('Enter a Card Slot')
    CONNECT BY
    PRIOR CIRC_PATH_ELEMENT.CIRC_PATH_INST_ID =
    CIRC_PATH_ELEMENT.PATH_INST_ID
    AND ELEMENT_TYPE != 'K' ) QUER
    WHERE
    circ.circ_path_inst_id = QUER.CIRC_PATH_INST_ID
    and circ.cust_inst_id = cust.cust_inst_id (+)
    ORDER BY
    LEV DESC , CIRC.PATH_NAME ASC, CIRC.BANDWIDTH ASC
    Thanks
    DG

    Hi John
    Thanks. I looked at your URL. I do have package. Just using procedure. So my initialization string (For stored proc in Physical Layer of RPD) is
    exec demo.add_employee(VALUEOF(NQ_SESSION.empid1));
    But when I run request in Answer I get the error
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 900, message: ORA-00900: invalid SQL statement at OCI call OCIStmtExecute: exec demo.add_employee(105); . [nQSError: 17011] SQL statement execution failed. (HY000)
    What should I put in initialization string in RPD?
    Thanks
    DG

  • Safari can't open a website because Mac OS X doesn't recognize Internet addresses starting with "http:". WHAT??

    Today I have been receiving intermittent error messages while running Safari v5.0.6 on my iMac running Mac OS X v 10.5.8 that Safari cannot open internet sites starting with https: or http: because OS X does not recognize https: or http:. It seems to be happening when I try to click on links within pages directing me to other info (on secure web pages).
    Clearly there is something very weird going on, as obviously this site is one that starts with https: and I am here posting to the community. Has anyone else seen this?
    What is this all about? It worked fine yesterday - I have made no changes to anything. Safari has been running like a slug the past few weeks. I have Apple auto update set to check for updates daily - so I truly have no idea were this is coming from. Any guidance would be apprecited! Thx -

    Hello  - anyone have any comments for me on this? Thx -

  • How to perform order by in START with connect by ?

    I am using the start with function to call range of bom code. Here is the code :
    SELECT level BOM_LEVEL, BCODE, bi_item_code,bi_qty
    FROM OM_BOM, OM_BOM_ITEM_DETAIL, OM_ITEM_PLANT_PROPERTY_HEAD,
    OM_ITEM_PLANT_PROPERTY_DETAIL, OM_ITEM
    WHERE BOM_CODE = BI_BOM_CODE          
    AND IPH_SYS_ID = IPD_IPH_SYS_ID
    AND IPH_PLANT_CODE = IPD_IPH_PLANT_CODE
    AND IPH_ITEM_CODE = IPD_IPH_ITEM_CODE
    AND IPH_GRADE_CODE_1 = IPD_IPH_GRADE_CODE_1
    AND IPH_GRADE_CODE_2 = IPD_IPH_GRADE_CODE_2
    AND IPH_ITEM_CODE = ITEM_CODE
    AND NVL(ITEM_FRZ_FLAG_NUM,2) = 2
    AND IPH_APP_CODE_NUM = 1
    AND BOM_ITEM_CODE = IPH_ITEM_CODE
    AND BOM_CODE = BI_BOM_CODE
    AND     NVL(BOM_DEVELOPMENT_YN_NUM, 2) = 2    commented by vellingiri.n on 22/06/2007 for enabling the development BOM
    AND NVL(BOM_FRZ_FLAG_NUM, 2) = 2
    AND IPD_ATTR_CODE = 'DFLT_BOM_CODE'
    AND IPD_ATTR_VALUE IS NOT NULL          
    AND BOM_CODE = IPD_ATTR_VALUE
              CONNECT BY PRIOR BI_ITEM_CODE = BOM_ITEM_CODE
              AND PRIOR BI_LOWEST_LEVEL_YN                    = 'N'           
    --START WITH BOM_CODE                = :PWH_BOM_CODE
         START WITH ( BOM_CODE >= :F_BOM AND BOM_CODE <= :T_BOM )     
    The range is from bom code : 95-01-001 to 95-01-002
    And the output is :-
    Bom Level____bom_code____Bom_item_code_________bi_qty
    1____________95-01-001____95-01-001______________1
    1____________95-01-001____50-23-008______________2
    1____________95-01-001____50-37-001______________1
    2____________50-37-001____59-01-001______________2
    2____________50-37-001____4230112_______________2
    3____________59-01-001____132133________________4
    2____________50-23-008____232323________________5
    2____________50-23-008____12-11-22_______________3
    1____________95-01-002____232323________________5
    2____________95-01-002____232311________________1
    ........ and more
    My problem right now, I want to group the bom so that I will be know the total qty of each bom from the range of bom that I count. That output was shown when I run the query in sql. But when I put into report 6i, the grouping has caused the arrangement of my bom runing up and down. How can I control the bom or any group funtion that I can used so that it will group the bom before start with a new bom ???
    please help me. Thanks.
    Lim

    You wrote that the output in SQL*Plus is correct but not in Oracle Reports 6i.
    Seems to me you have a Reports issue and should ask in that forum.

  • Required query perfomance tuning which has START WITH CONNECT BY PRIOR

    Hi,
    I have below small query and the CDDS table with 40+ million records.
    SELECT -LEVEL, COMPONENT_ID, COMPONENT_TYPE, COMPONENT_STATUS,
    PARENT_COMPONENT_ID, PARENT_COMPONENT_TYPE, other_info
    BULK COLLECT INTO ltbl_cdds_rec
    FROM CDDS
    START WITH
    PARENT_COMPONENT_ID IN
    ( SELECT dns_name
    FROM RAS_CARD
    WHERE ras_name = <<INPUT_PARAMATER>>
    AND parent_component_type = 'CT_NRP')
    CONNECT BY PARENT_COMPONENT_ID = PRIOR COMPONENT_ID;
    To process this query, its taking 3 hours.
    Please suggest the way forward to tune the query for better performance.

    Create statement for CDDS:
    CREATE TABLE CDDS
    COMPONENT_TYPE VARCHAR2(30 BYTE),
    COMPONENT_ID VARCHAR2(255 BYTE),
    PARENT_COMPONENT_TYPE VARCHAR2(30 BYTE),
    PARENT_COMPONENT_ID VARCHAR2(255 BYTE),
    COMPONENT_VERSION_NO VARCHAR2(30 BYTE),
    COMPONENT_STATUS VARCHAR2(30 BYTE),
    ODS_CREATE_DATE DATE,
    ODS_LAST_UPDATE_DATE DATE,
    OTHER_INFO VARCHAR2(255 BYTE)
    TABLESPACE APPL_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    NOMONITORING
    ENABLE ROW MOVEMENT;
    Create statement for RAS_CARD:
    CREATE TABLE RAS_CARD
    RAS_NAME VARCHAR2(20 BYTE),
    SLOT VARCHAR2(2 BYTE),
    RAS_CARD_ID VARCHAR2(30 BYTE),
    CARD_TYPE VARCHAR2(5 BYTE),
    IP_ADDRESS VARCHAR2(15 BYTE),
    DNS_NAME VARCHAR2(255 BYTE),
    STATUS VARCHAR2(15 BYTE),
    NRP_NO CHAR(2 BYTE),
    NRP_TOTAL_ALLOC_CAPACITY NUMBER(10),
    CREATED_BY VARCHAR2(10 BYTE),
    NRP_ALLOCATED_CAPACITY NUMBER(10),
    NIDB_DRA2_KEY VARCHAR2(15 BYTE),
    NIDB_DRN1_KEY CHAR(6 BYTE),
    ODS_CREATE_DATE DATE,
    LAST_UPDATED_BY VARCHAR2(10 BYTE),
    ODS_LAST_UPDATE_DATE DATE,
    WATERMARK NUMBER(38)
    TABLESPACE APPL_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 1M
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    NOLOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    NOMONITORING;
    Explain Plan for the below query:
    select * from CDDS
    where PARENT_COMPONENT_ID IN
    ( SELECT dns_name
    FROM RAS_CARD
    WHERE ras_name = <<INPUT_PARAMATER>>
    | Id | Operation | Name | Rows | Bytes | Cost | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 1 | 107 | 12 | | |
    | 1 | TABLE ACCESS BY INDEX ROWID| CDDS | 1 | 62 | 1 | | |
    | 2 | NESTED LOOPS | | 1 | 107 | 12 | | |
    | 3 | SORT UNIQUE | | | | | | |
    |* 4 | TABLE ACCESS FULL | RAS_CARD | 4 | 180 | 6 | | |
    | 5 | PARTITION RANGE ITERATOR | | | | | KEY | KEY |
    |* 6 | INDEX RANGE SCAN | CDDS_I02 | 10 | | 1 | KEY | KEY |
    ---------------------------------------------------------------------------------------------

  • How cant i start with iphon 4g what program ineed to download to my pc to contact my iphone

    how cant i start with iphon 4g? what kind of program ineed to download to my pc to contact my ihone?

    how cant i start with iphon 4g?There is no iPhone "4g".  Do you mean the iPhone 4 or the iPhone 3G?

Maybe you are looking for