Legacy and hierarchical queries

Hi all

Using the RDBMS 11.2.0.3, I would like to know if there was a way to "inherit" a parent row values when you use a hierarchical query.

For example, with these values:

CREATE TABLE foohh (
 id NUMBER,
 parent NUMBER,
 name VARCHAR2(64),
 continent VARCHAR2(32)
);

INSERT INTO foohh VALUES ( 1, null, 'United States', 'AMERICA' ) ;
INSERT INTO foohh VALUES ( 2, 1, 'California', null ) ;
INSERT INTO foohh VALUES ( 3, 2, 'San Francisco', null ) ;
INSERT INTO foohh VALUES ( 4, 3, 'Golden Gate', null ) ;
INSERT INTO foohh VALUES ( 5, null, 'China', 'ASIA' ) ;
INSERT INTO foohh VALUES ( 6, 5, 'Beijing', null ) ;
INSERT INTO foohh VALUES ( 7, 6, 'Great Wall', null ) ;

I would like to be able to view the continent of all lines.

The following query returns the leaves, but I don't see their continent:

SELECT
 id
 ,connect_by_root(parent) parent
 ,sys_connect_by_path(name, '-->') path
 ,nvl( continent, 'unknown' ) continent
FROM foohh
WHERE
 connect_by_root(parent) is null
 and connect_by_isleaf=1
CONNECT BY PRIOR id=parent
;

CONTINENT OF PARENT ID PATH
---------- ---------- ------------------------------------------------------------ ------------------------------
4-> United States-> California-> San Francisco-> Golden Gate unknown
7-> China-> Beijing-> great unknown wall

Is there a clever way to do this?

Thank you

Anthony

Include below in him SELECT query.

Continent CONNECT_BY_ROOT

Tags: Database

Similar Questions

  • Hierarchical queries - problem with condition "begins by".

    Hi people

    I play with the connection by and start with clause and am faced with a particular problem which I can not solve...

    My data set is:

    Create table dates_q
    (start_date date,
    end_date date)
    /
    

    REM INSERTING into dates_q
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('01-JAN-14','DD-MON-RR'),to_date('10-JAN-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('11-JAN-14','DD-MON-RR'),to_date('20-JAN-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('10-MAR-14','DD-MON-RR'),to_date('20-MAR-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('21-MAR-14','DD-MON-RR'),to_date('31-MAR-14','DD-MON-RR'));
    Insert into dates_q ("START_DATE","END_DATE") values (to_date('01-APR-14','DD-MON-RR'),to_date('10-APR-14','DD-MON-RR'));
    

    Now I basically just want to get your hands on hierarchical queries and working with the syntax of various...

    What I now want is, start with the date of April 1 as my start date and work backward to build my 'tree '. The condition of my tree is between two rows; my start and end dates differ from 1 day. If they do not; I don't want these records in my tree.

    And using sys_connect_by_path, I want to get all the way from the root.

    Thus, for example,.

    SELECT a.*,
           sys_connect_by_path(start_date, '|'),
           LEVEL lvl
      FROM dates_q a
     CONNECT BY PRIOR end_date = (start_date - 1)
    

    I get the following output

    START_DATEEND_DATESYS_CONNECT_BY_PATH(START_DATE,'|')LVL
    01.01.201410.01.2014| 1 JANUARY 141
    11.01.201420.01.2014| 1 JANUARY 14 | JANUARY 11, 142
    11.01.201420.01.2014| JANUARY 11, 141
    10.03.201420.03.2014| MARCH 10, 141
    21.03.201431.03.2014| MARCH 10, 14. MARCH 21, 142
    01.04.201410.04.2014|10-MAR-14|21-MAR-14|01-APR-143
    21.03.201431.03.2014| MARCH 21, 141
    01.04.201410.04.2014| MARCH 21, 14. 1 APRIL 142
    01.04.201410.04.2014| 1 APRIL 141

    But for the moment I did not have any starting point... Now comes the FUN part...

    When I give the State of departure; I get a single row :-(

    Example of

    SELECT a.*,
           sys_connect_by_path(start_date, '|'),
           LEVEL lvl
      FROM dates_q a
     CONNECT BY PRIOR end_date = (start_date - 1)
     START WITH start_date = To_Date('01-apr-2014','dd-mon-yyyy');
    

    The result is

    START_DATEEND_DATESYS_CONNECT_BY_PATH(START_DATE,'|')LVL
    01.04.201410.04.2014| 1 APRIL 141

    Just a line...!

    I'm unable to understand this and work more and need help.

    The formation of the tree works only in a 'sense' and I'm going the other way around? Don't know what it means but just something that comes to mind. :/

    Thank you

    K

    P.S. - database is 10g R2.

    Hello

    Thanks for the display of the data of the sample; It is very useful.

    What do you expect the result will be and why?

    LEVEL = 1 contains all rows that meet the condition to START WITH.  The rows that meet the condition

    start_date = To_Date('01-apr-2014','dd-mon-yyyy')

    in this case?  Only the line you actually obtained.

    LEVEL = N (where N > 1) contains all rows that meet the conditions regarding some FRONT CONNECT BY rank level = N - 1.  Since the only line level = 1 to end_date = To_Date('10-apr-2014','dd-mon-yyyy'), lines satisfy the condition

    End_date PRIOR = (start_date - 1).

    ? None.  End_date PREREQUISITE is April 10, while rows with start_date April 11 would fulfill this condition, there is no line on LEVEL = 2 and the query stops there.

    You would have expected this from your previous results.  The line with the start_date April 1 had no children in the previous application, so there no children in any application that has the same State of CONNECT BY.

    Maybe you meant the CONNECT BY condtion to be

    End_date = BEFORE (start_date - 1).

  • Reg: Prior in hierarchical queries:

    Hi Experts,

    A little doubt - I've been working on the requests, but it still haunts me... Hierarchical queries
    One thing I am more confused about is the prior clause.

    I'll try to explain my concern below.
    Here, the tree yesterday gets reversed by changing the clause PRIOR to 'Manager Id' to 'Employee Id' and vice versa.

    Exactly how to understand where to put FORWARD... which column?
    I can get my results just double check... but I just want to know the concept. So stupid right... but do not want to take this doubt more far. ;)
    ranit@XE11GR2>> select * from
      2  emp;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7369 SMITH      CLERK           7902 17-DEC-08        800                    20
          7566 NORGAARD   MANAGER         7839 01-APR-07       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-07       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-09       2850                    30
          7782 FOOTE      MANAGER         7839 09-JUN-08       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 ELLISON    PRESIDENT            17-NOV-06       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-08       1500          0         30
          7876 ADAMS      CLERK           7788 18-JUN-07       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-07        950                    30
          7902 LOFSTROM   ANALYST         7566 04-DEC-08       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-08       1300                    10
    
    12 rows selected.
    
    Elapsed: 00:00:00.04
    ranit@XE11GR2>> select * from
      2  emp
      3  connect by empno  = prior mgr
      4  start with empno = 7698;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7698 BLAKE      MANAGER         7839 01-MAY-09       2850                    30
          7839 ELLISON    PRESIDENT            17-NOV-06       5000                    10
    
    Elapsed: 00:00:00.01
    ranit@XE11GR2>> select * from
      2  emp
      3  connect by prior empno = mgr
      4  start with empno = 7698;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7698 BLAKE      MANAGER         7839 01-MAY-09       2850                    30
          7654 MARTIN     SALESMAN        7698 28-SEP-07       1250       1400         30
          7844 TURNER     SALESMAN        7698 08-SEP-08       1500          0         30
          7900 JAMES      CLERK           7698 03-DEC-07        950                    30
    
    Elapsed: 00:00:00.07
    Please help guys.
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE     11.2.0.2.0     Production"
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Thank you
    Vanessa B.

    I know the feeling!

    START WITH gives you the first line of the result set.

    CONNECT BY gets you the next row. At this point, you already have is the "before" line and the line that you get is the current line.

    If the current line is supposed to be the Manager of the previous line, this means that Bishop PREREQUISITE = empno.

    If the previous line is supposed to be the Manager of the current line, which means PRIOR empno = mgr.

    Think AHEAD as referring to the line that you just received and "without any preconditions" as the line you want.

    Another way of thinking that is to ask "what new information I receive?

    If you say "Bishop PREREQUISITE = empno", you already know the Director of the previous row. New information will be the Director of the current line. As you continue, you will learn step by step who are managers.

    If you say "PRIOR empno = mgr", you already know that the employee of the previous row. New information will be the new empno. So step by step, you will find the empnos.

    You always ' move to before current. "Of mgr to empno" descends from the string, "empno to Bishop" goes to the top of the chain.

    Published by: stew Ashton on February 16, 2013 11:57

  • Gites join vs hierarchical queries

    Hello

    Please tel me who must use a 1?
    I have to get job list of the simple Manger, should I use self-join or hierarchical queries (CONNECT BY and earlier versions)?

    Yours sincerely

    Hello

    944768 wrote:
    Hello

    Please tel me who must use a 1?
    I have to get job list of the simple Manger, should I use self-join or hierarchical queries (CONNECT BY and earlier versions)?

    It depends on your data and your needs.

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) for all the tables involved, so people who want to help you can recreate the problem and test their ideas. Also post the results you want from this data, as well as an explanation of how you get these results from these data.
    Explain, using specific examples, how you get these results from these data.
    If you show what the problem using commonly available tables (suc as scott.emp, who has a hierarchy of level 4), then you do not have ot post sample data, just the results and explanations.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

    If your hierarchy consists only of 2 levels, then a self-join will be probably more effective, simpler code and easier to maintain.

    If you don't know how many levels in the hierarchy, then self-join is not an option. Use CONNECT BY or, if you have Oracle 11.2, a WITH recursive clause.

    If you have a fixed number of levels (or an upper limit) greater than 2, then CONNECT BY (or a WITH recursive clause) will probably be the best.

  • How to order a tree balanced with SQL hierarchical queries

    by searching the forum I found this

    Re: Generate tree balanced with SQL hierarchical queries

    is there a way I can order this tree in alphabetical order so that the result looks like

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 BLAKE
    3 ALLEN
    3 JAMES
    MARTIN 3
    3 TURNER
    WARD 3
    2 CLARK
    3 MILLER
    2 JONES
    3 FORD
    4 SMITH
    3 SCOTT
    4 ADAMS

    -the original query-

    SELECT THE LEVEL
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    ;

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 JONES
    3 SCOTT
    4 ADAMS
    3 FORD
    4 SMITH
    2 BLAKE
    3 ALLEN
    WARD 3
    MARTIN 3
    3 TURNER
    3 JAMES
    2 CLARK
    3 MILLER

    Hello

    Bodin wrote:
    Hi Frank, I can order it selectively depending on the level, which means that only siblings stopped at third level, but rest of the brothers and sisters remain Nations United ordered

    It's actually quite difficult. You can "ORDER of brothers and SŒURS BY CASE... ', like this:

    SELECT  LEVEL
    ,      LPAD (' ', 3 * LEVEL) || ename     AS indented_ename
    FROM      scott.emp
    START WITH        mgr     IS NULL
    CONNECT BY         mgr      = PRIOR empno
    ORDER SIBLINGS BY  CASE
                   WHEN  job = 'MANAGER'  THEN  ename
                                              ELSE  NULL
                 END
    ;
    

    In this case to get desired results in table scott.emp, as the lines are LEVEL = 2 if and only if use = "MANAGER".
    But if you reference LEVEL in the CASE expression (for example, if you replace ' job = 'MANAGER' ' with "2 LEVEL =" above "), then you will get the error" ORA-00976: LEVEL, PRIOR or ROWNUM not allowed here. "
    The best way I can think to do exactly what you asked is to do 2 CONNECT BY queries; one just to get the LEVEL and the other for the brothers and SŒURS ORDER BY:
    {code}
    WITH got_lvl AS
    (
    SELECT LEVEL AS lvl
    Bishop
    empno
    ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    OF got_lvl
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    BROTHERS AND SŒURS OF ORDER OF CASES
    ONCE lvl = 2 THEN ename
    ANOTHER NULL
    END
    ;
    {code}
    Why you can't simply "Brothers and SŒURS of ORDER BY ename" at all levels? If all you care is the order of the items of LEVEL = 2, then this is probably the most effective and simplest way. It really hurt anything if nodes on levels 3, 4, 5,... are in order, too?

    Here's something you can do if you want to order by different unique things to different levels:
    {code}
    WITH got_sort_key AS
    (
    SELECT LEVEL AS lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    empno
    SYS_CONNECT_BY_PATH (LPAD (CASE
    WHEN LEVEL = 2
    THEN ename
    Of OTHER TO_CHAR (empno)
    END
    10
    )
    , ','
    ) AS sort_key
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    indented_ename
    empno
    OF got_sort_key
    ORDER BY sort_key
    ;
    {code}
    However, all possible values of the CASE expression must uniquely identify the node; otherwise, the output won't necessarily hierarchical order. You can assign arbitrary unique IDS to the lines (using the ROW_NUMBER analytic function, for example), but that requires another subquery and is also complex and perhaps as ineffective as the solution above with 2 garages CONNECT.

  • Legacy and the color of corruption

    Hello

    A few questions.
    1. I just downloaded the latest Illustrator and when I save files a guest wrote that I'm saving for Legacy and I can lose some content. There is nothing in the Adobe manual that says what is inheritance. Made a browsw outside of Adobe and it seems the legacy can be old software? Is the right one? How the last download would be old version? See the first photo

    Capture2.JPG

    2. If I click OK and open the file again and the horizon is corrupted > see photo

    Capture1.JPG

    3. I then try and fix the color on the spectrum of color fill and as all can see that the spectrum of color shows a purple shade fill shows only the grey hue. and I can't change this setting for color in the layer? object is selected & document all RGB. See photo >Capture3.JPG

    Summary >
    I don't know if this problem is related to the prompt "inherited" or if I have two big problems of corruption of the color of certain objects and given the obsolete software.

    Clues much appreciated, thanks
    Wayne

    Salah is correct.

    Existing versions are older versions of the file format.

    Do a save as... and save it in the latest version of CC.

  • File save to preserve search and replace queries when reinstalling?

    I need to uninstall and reinstall CS6. I have a large number in search and replace queries that would be extremely difficult to redefine. How do I save these as well as other features such as the areas of work or Actions in PhotoShop?

    Your saved queries find/replace are in a folder in your library to the user or the user's profile (depending on your operating system). You can find the path to where they are stored in the information provided for the InDesign Defaults file to replace your preferences. The folder queries saved is in the same folder as the InDesign Defaults file. Note that this is a HIDDEN on all recent operating systems folder.

    There was also a case of workspaces in the same place for ID. Similar records should be found for other programs under their respective application folders to the same location of the user's library/profile.

  • On the report templates in the Apex and report queries

    Hi all.

    I'm reading about models and report queries and asks me to use cases of these options. I have two questions:

    -Can be used to print reports of special loyalty, such as printing a document (invoice, invoice, check)?

    -Make the report accept queries settings? for example, you can filter specific data...?

    Any other uses?

    Best regards, Luis...!

    Your welcome. Review the marking of the answers correct or useful in order to help other people traveling the same road. :)

  • How to duplicate a composition of legacy and make it independent of the original

    Hi, im trying to duplicate a composition of legacy and make it independent of the original, but it seems to be impossible... im working on CS5.

    Can someone help me please?

    Thank you

    As Andrew says, select a composition in the project, not in the timeline panel, and then press Ctrl/Cmnd + D. You will get a new comp with a number or a copy appended to the name. This model is completely independent of the original, but it contains all the same images.

    If the model you duplicated contains other compositions nested in the timeline, then these nested compositions must also be duplicated and their duplicates used to replace the original compositions nested in the double model. The script is called, it's easy. Most of the projects created by new users have not a lot of nested compositions is not usually a big deal to do this step by hand.

    If you post a screenshot of the timeline for the model that you have duplicated or better yet the chart we can highlight exactly what needs to be duplicated in the project Panel to give you an independent composition double. Duplication of a composition that is nested in a chronology does not give you a single copy.

    One last thing. Any time you select layers in your timeline and dial before them, you create a new composition now nested in your original. It is a good practice to organize all prior comps in the project Panel in a folder with a name that lets you know where to go these comps before. This will make the job of duplicating main compositions much easier.

  • hierarchical queries - error: ORA-30929: clause ORDERBY brothers and SŒURS unauthorized

    Hello

    I have a hierarchical query in which, I automatically generate unordered list. I needed to get the children in the same level, so I used the brothers and sisters of the order by clause, but the procedure did not compile and threw an error Ora-30929 - brothers and sisters Order By Clause not allowed here.

    This is the query.

    SELECT CASE WHEN LAG(LEVEL,1,0) (ORDER OF ROWNUM) > = LEVEL THEN "< li >".
    (Level) lead CASE of OTHER COURSES (ORDER OF ROWNUM) WHEN LEVEL THEN
    CASE WHEN ROWNUM = 1 THEN ' < ul id = "sidebarmenu1" 'ELSE' < ul' END | ' > < li > '
    On the OTHER CASE WHEN ROWNUM = 1 THEN ' < ul id = "sidebarmenu1" 'ELSE' < ul ' END: ' > < li > ' END END |
    "< span >' | daevmt.short_menu_item |' </span >' |
    LEVEL of CASE - LEAD(LEVEL,1,1) (ROWNUM ORDINANCE) WHEN - 1 THEN NULL WHEN 0 THEN "< /li >".
    ELSE REPLACE (LPAD ('* ', LEVEL-LEAD(LEVEL,1,1) (ORDER OF ROWNUM),'* '), ' * ',' < /li > < /ul > < /li > ')
    END | CASE WHEN AHEAD (LEVEL, 1, 0) (ORDER OF ROWNUM) = 0 THEN '< /ul >"END of another null unordered_list, daevmt.menu_item, daevmt.link_url, daevmt.menu_id,.
    daevmt.above_menu_id
    OF dae_vs_my_tasks daevmt
    START WITH daevmt.above_menu_id = "TOPMENU".
    CONNECT BY PRIOR = daevmt.above_menu_id Daevmt.menu_id
    Brothers and SŒURS of ORDER BY daevmt.display_order;

    Can someone please help what is wrong in my query?

    Thanks in advance,

    Natarajan

    Published by: Nikita on March 7, 2011 23:26

    Published by: Nikita on March 7, 2011 23:28

    Published by: Nikita on March 7, 2011 23:28

    According to the Oracle documentation, this error is caused by 'ORDER brothers' and SŒURS clause of having in a query that is not a "CONNECT BY" clause that is clearly not the case here. I suspect it's because you use analytical functions 'LEAD' and 'LAG '. I took your statement, replaced the names of table and column with some in a table, I also has a structure of hierarchical and got the same error. After removing all the functions of 'LEAD' and 'LAG' it run OK.
    I don't think that helps you all.
    You may create another table with the contents of this table by adding 4 columns for rownum, level (level) lead and lag (level). Then use this table to generate your unsorted list html code.

  • Count queries and hierarchical

    Hi Oracle SQL gurus,

    Need your help in getting the counts of children for each parent - relationship to child using a hierarchical query.

    BANNER
    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL VERSION 10.2.0.1.0 - PRODUCTION


    Set of data to the top:

    SELECT 1 AS PROJECT,-1 AS PARENT_ID, CHILD_ID OF DOUBLE 1
    UNION
    SELECT 1, 1, 2 DOUBLE
    UNION
    SELECT 1, 2, 3, THE DOUBLE
    UNION
    SELECT 1, 3, 4 OF THE DOUBLE
    UNION
    SELECT 2, -1, 5 DOUBLE
    UNION
    SELECT 3, -1, DOUBLE 6
    UNION
    SELECT THE 3, 6, 7 DOUBLE

    Expected results:

    SELECT 1 AS project, -1 AS PARENT_ID, CHILD_ID AS, 4 as EXPECTED_ROW_COUNT FROM DUAL 1
    UNION
    SELECT 1, 1, 2, 3 DOUBLE
    UNION
    SELECT 1, 2, 3, 2 OF THE DOUBLE
    UNION
    SELECT 1, 3, 4, 1 DOUBLE
    UNION
    SELECT 2, -1, 5, 1 DOUBLE
    UNION
    SELECT 6-1, 2, 3 DOUBLE
    UNION
    SELECT 3, 6, 7, 1 FROM DUAL;


    Help, please.

    Thank you in advance.

    Hello

    Here's one way:

    SELECT       project_id, parent_id, child_id
    ,        COUNT (*)     AS expected_row_count
    FROM       table_x
    CONNECT BY     child_id     = PRIOR parent_id
    GROUP BY  project_id, parent_id, child_id
    ;
    
  • Slow hierarchical queries

    Hello
    I wrote an application that allows the user to filter the data displayed based on several parameters, for example one of the parameters (b) is hierarchical, each element (with the exception of the root element) has a father and several sons, the hierarchy is managed by a specific table (LINKS), I need when the user selects b the result will include also all his descendants.

    This is the query:

    SELECT *.
    R
    JOIN IN-HOUSE RT ON R.A = RT. A
    WHERE (R.B IN (select sub_id
    the beginning of LINKS with father_id =: id
    Connect prior sub_id = father_id)
    or R.B =: id or: id = 0)
    AND (R.A =: GOLD: a = 0)
    ORDER OF R.B, R.A

    The problem is that the query is so slow, it allows the application of stuck, when I've omitted the line: ' or R.B =: id or: id = 0 ' he not stuck but this line is necessary because the user may also fill the filter field or try to filter b himself and not his descendants.

    Is it possible to improve the performance of this query or write it better?

    You can move the logic on r.b in the subquery.
    There is a small chance that it could accelerate the entire query.
    not tested

    SELECT *
    FROM R
    JOIN RT ON R.A = RT.A
    WHERE R.B IN (select sub_id
                       from LINKS
                       start with father_id = :id
                       connect by prior sub_id= father_id
                       UNION ALL
                       select :id sub_id from dual
                       UNION ALL
                       select sub_id
                       from LINKS
                       where :id = 0
                       )
    AND (R.A=:a or :a=0)
    ORDER BY R.B, R.A
    

    Also see the ecexution use it and explain how to call the select statement.
    A goal of optimization often used is wo writing several queries and call the right according to the parameters.
    Different queries may be optimized independently of each other and hence faster query where everything is condensed into one big.

    pls/sql example

    if :a=0 and :b=0 then
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       ORDER BY R.B, R.A;
    elsif :b=0 then
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       where R.A=:a
       ORDER BY R.B, R.A;
    elsif :a=0 then
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       WHERE R.B IN (select sub_id
                       from LINKS
                       start with father_id = :id
                       connect by prior sub_id= father_id
                       UNION ALL
                       select :id sub_id from dual)
       ORDER BY R.B, R.A;
    else /* both parameters are selected */
       SELECT *
       into...
       FROM R
       JOIN RT ON R.A = RT.A
       WHERE R.B IN (select sub_id
                       from LINKS
                       start with father_id = :id
                       connect by prior sub_id= father_id
                       UNION ALL
                       select :id sub_id from dual)
       and R.A=:a
       ORDER BY R.B, R.A;
    end;
    
  • hierarchical queries: output: display all folder paths. entry: Folder1, folder2

    I have a table called 'File' with the data indicated below. I want the sql query to show the hierarchical output.
    Enter values for the query: 2-11 tree shows two points (see "Input2" and "Input11"). The query now takes the values 2 and 11 and outputs hierarchical tree from root (see "Root") to the final sheets ('2, '12'), while the entries are as points of 'touch' inside the full tree-path, so I have the necessary output should be like 5 rows:

    (0, null)-parent of the two inputs
    (2, 0) - input2
    (10,0) - parents of 'input11 '.
    (11: 10) - input11
    (12: 11) - leaf


    I don't know how to write this query. Can help you.
    Something like:

    "Select...".
    Connect prior ID = PARENT_ID.

    --

    Table "Folder" (ID, PARENT_ID).

    Column PARENT_ID reference ID to create the hierarchy.
    Example of data in the table:

    (0, null)-root
    (1, 0) - child '1 '.
    (2, 0) - Input2
    (3, 1)
    (10,0) - child "10".
    (11: 10) - chilc-child "11", Input11
    (12: 11) - chilc-child "12".

    Hello

    If you want to ignore a few lines in the file and only pay attention to the parameters, their ancestors and their descendants. Is this fair?
    If so, do CONNECT it BY query on the results of a subquery which includes only the desired lines. In the example below, this query Tahina is be a UNION of two other CONNECT BY queries: one to get the ancestors of the parameters and the other for their descndents.

    VARIABLE     input_a     NUMBER
    VARIABLE     input_b     NUMBER
    EXEC  :input_a := 2;
    EXEC  :input_b := 11;
    
    WITH     universe     AS
    (
         -- Descendents of parameters
         SELECT     id,     parent_id
         FROM     folder
         START WITH     parent_id     IN (:input_a, :input_b)
         CONNECT BY     parent_id     = PRIOR id
         --
        UNION
         -- Ancestors of parameters
         SELECT  id,     parent_id
         FROM     folder
         START WITH     id     IN (:input_a, :input_b)
         CONNECT BY     id     = PRIOR parent_id
    )
    SELECT     SYS_CONNECT_BY_PATH (id, '/')     AS path
    FROM     universe
    START WITH     parent_id     IS NULL
    CONNECT BY     parent_id     = PRIOR id
    ;
    

    Output of your sample data:

    PATH
    ------------------------------
    /0
    /0/2
    /0/10
    /0/10/11
    /0/10/11/12
    
  • How can I get reid of the icon "view and manage queries Google" yo the right of the URL?

    If I try to get if rid of by customizing the tool bar, the URL field disappears as well.

    You have a circle with a 'g' on this subject in the address bar? It's the Google extension disconnect.

    You can remove extension Google cut off because you have the most recent extension of disconnection (icon "D"). See: https://disconnect.me/help#legacy-products-facebook-google-and-twitter-disconnect-and-collusion_faq

    You would do that on the page modules. Either:

    • CTRL + SHIFT + a
    • "3-bar" menu button (or tools) > Add-ons

    In the left column, click Extensions.

    What is fix?

  • Hierarchical queries for subnets

    I need to write a hierarchical query for quite a number of (contiguous groups of IP addresses) IP subnets. What I'm hoping to do, is let the database do the bulk of the work here and I will not need to write code to do this. I'll do that if I have to but I would really rather not.

    General information may be in order for those who do not know subnets. IP subnets have unique characteristics, based on network management standards (caveat: I'm not a guru/subnet on the network, but I know enough to be dangerous). The first thing to know is that a subnet is a contiguous block of IP addresses that help define the IP network protocol. Another thing is that an IP address can be converted to a binary or decimal/numeric value. This is useful because it can take us out of the sphere of analysis of strings and comparing a group of text values, which will eventually be converted to numbers in order to make meaningful comparisons anyway.

    The result is that subnets can be defined by digital upper and lower limits. And the trick here is that some of these blocks of IP addresses live in the other blocks. Look at the data below and I'll explain if you need. In addition, the network address is the lower limit of the subnet and dissemination is the upper limit. This is a create table and examples of data from my dataset where you can see the IP addresses and name of each subnet and numeric limits for each subnet.

    CREATE TABLE "SUBNET_DECIMAL_VALS" 
       (    
        "SUBNET" VARCHAR2(4000 BYTE), 
        "CIDR_BLOCK" VARCHAR2(30 BYTE), 
        "NETWORK" VARCHAR2(4000 BYTE), 
        "BROADCAST" VARCHAR2(4000 BYTE), 
        "NETWORK_DEC" NUMBER, 
        "BROADCAST_DEC" NUMBER
       ) ;
    

    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.0.0/20','/20','128.110.0.0','128.110.15.255',2154692608,2154696703);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.1.0/24','/24','128.110.1.0','128.110.1.255',2154692864,2154693119);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.4.0/22','/22','128.110.4.0','128.110.7.255',2154693632,2154694655);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.8.0/22','/22','128.110.8.0','128.110.11.255',2154694656,2154695679);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.12.0/22','/22','128.110.12.0','128.110.15.255',2154695680,2154696703);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.16.0/21','/21','128.110.16.0','128.110.23.255',2154696704,2154698751);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.16.0/22','/22','128.110.16.0','128.110.19.255',2154696704,2154697727);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.20.0/22','/22','128.110.20.0','128.110.23.255',2154697728,2154698751);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.24.0/22','/22','128.110.24.0','128.110.27.255',2154698752,2154699775);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.28.0/22','/22','128.110.28.0','128.110.31.255',2154699776,2154700799);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.28.0/24','/24','128.110.28.0','128.110.28.255',2154699776,2154700031);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.29.0/24','/24','128.110.29.0','128.110.29.255',2154700032,2154700287);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.30.0/24','/24','128.110.30.0','128.110.30.255',2154700288,2154700543);
    Insert into SUBNET_DECIMAL_VALS (SUBNET,CIDR_BLOCK,NETWORK,BROADCAST,NETWORK_DEC,BROADCAST_DEC) values ('128.110.31.0/24','/24','128.110.31.0','128.110.31.255',2154700544,2154700799);
    

    SELECT * FROM SUBNET_DECIMAL_VALS
    subnet            cidr   network          broadcast        network_dec   broadcast_dec
    128.110.0.0/20    /20    128.110.0.0      128.110.15.255   2154692608    2154696703
    128.110.1.0/24    /24    128.110.1.0      128.110.1.255    2154692864    2154693119
    128.110.4.0/22    /22    128.110.4.0      128.110.7.255    2154693632    2154694655
    128.110.8.0/22    /22    128.110.8.0      128.110.11.255   2154694656    2154695679
    128.110.12.0/22   /22    128.110.12.0     128.110.15.255   2154695680    2154696703
    128.110.16.0/21   /21    128.110.16.0     128.110.23.255   2154696704    2154698751
    128.110.16.0/22   /22    128.110.16.0     128.110.19.255   2154696704    2154697727
    128.110.20.0/22   /22    128.110.20.0     128.110.23.255   2154697728    2154698751
    128.110.24.0/22   /22    128.110.24.0     128.110.27.255   2154698752    2154699775
    128.110.28.0/22   /22    128.110.28.0     128.110.31.255   2154699776    2154700799
    128.110.28.0/24   /24    128.110.28.0     128.110.28.255   2154699776    2154700031
    128.110.29.0/24   /24    128.110.29.0     128.110.29.255   2154700032    2154700287
    128.110.30.0/24   /24    128.110.30.0     128.110.30.255   2154700288    2154700543
    128.110.31.0/24   /24    128.110.31.0     128.110.31.255   2154700544    2154700799
    

    What I tried to do is a hierarchical query traditional and used more than and less than the comparisons in the where clause. I'm trying to find the limits of subnet (top and bottom numbers) that match among other numerical limits. This is an example, and it gives me the results I need.

    select level, subnet, cidr_block cidr, network, broadcast, network_dec, broadcast_dec
    from poc_subnet_decimal_vals
    connect by nocycle prior network_dec > network_dec and broadcast_dec < broadcast_dec
    

    Do I have to create from this, it is something like this:

    Level    Subnet           CIDR    Network        Broadcast         Network_Dec   Broacast_Dec
    1        128.110.0.0/20    /20    128.110.0.0    128.110.15.255    2154692608    2154696703
    2        128.110.1.0/24    /24    128.110.1.0    128.110.1.255     2154692864    2154693119
    2        128.110.4.0/22    /22    128.110.4.0    128.110.7.255     2154693632    2154694655
    2        128.110.8.0/22    /22    128.110.8.0    128.110.11.255    2154694656    2154695679
    2        128.110.12.0/22   /22    128.110.12.0   128.110.15.255    2154695680    2154696703
    1        128.110.16.0/21   /21    128.110.16.0   128.110.23.255    2154696704    2154698751
    2        128.110.16.0/22   /22    128.110.16.0   128.110.19.255    2154696704    2154697727
    2        128.110.20.0/22   /22    128.110.20.0   128.110.23.255    2154697728    2154698751
    2        128.110.24.0/22   /22    128.110.24.0   128.110.27.255    2154698752    2154699775
    2        128.110.28.0/22   /22    128.110.28.0   128.110.31.255    2154699776    2154700799
    3        128.110.28.0/24   /24    128.110.28.0   128.110.28.255    2154699776    2154700031
    3        128.110.29.0/24   /24    128.110.29.0   128.110.29.255    2154700032    2154700287
    3        128.110.30.0/24   /24    128.110.30.0   128.110.30.255    2154700288    2154700543
    3        128.110.31.0/24   /24    128.110.31.0   128.110.31.255    2154700544    2154700799
    

    Once, I get a hierarchical query of good work I can do the rest of the formatting with the values of the path and CYCLE but I'm not able to get a basic querying work. Does anyone have an idea of how to go on this subject using SQL only? I can write a PL/SQL procedure to add an ID of parent to each row, and then I know that I can create a hierarchical query from that but I was trying to avoid this method if possible.

    Hello

    Earl Lewis wrote:

    I need to write a hierarchical query for quite a number of (contiguous groups of IP addresses) IP subnets. What I'm hoping to do, is let the database do the bulk of the work here and I will not need to write code to do this. I'll do that if I have to but I would really rather not.

    General information may be in order for those who do not know subnets. IP subnets have unique characteristics, based on network management standards (caveat: I'm not a guru/subnet on the network, but I know enough to be dangerous). The first thing to know is that a subnet is a contiguous block of IP addresses that help define the IP network protocol. Another thing is that an IP address can be converted to a binary or decimal/numeric value. This is useful because it can take us out of the sphere of analysis of strings and comparing a group of text values, which will eventually be converted to numbers in order to make meaningful comparisons anyway.

    The result is that subnets can be defined by digital upper and lower limits. And the trick here is that some of these blocks of IP addresses live in the other blocks. Look at the data below and I'll explain if you need. In addition, the network address is the lower limit of the subnet and dissemination is the upper limit. This is a create table and examples of data from my dataset where you can see the IP addresses and name of each subnet and numeric limits for each subnet.

    1. CREATE TABLE 'SUBNET_DECIMAL_VALS '.
    2. (
    3. VARCHAR2 (4000 BYTE) "SUBNET."
    4. VARCHAR2 (30 BYTE) "CIDR_BLOCK."
    5. VARCHAR2 (4000 BYTE) 'NETWORK ',.
    6. "BROADCASTING" VARCHAR2 (4000 BYTE),
    7. NUMBER OF "NETWORK_DEC."
    8. NUMBER OF 'BROADCAST_DEC '.
    9. ) ;
    1. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.0.0/20','/20','128.110.0.0','128.110.15.255',2154692608,2154696703);
    2. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.1.0/24','/24','128.110.1.0','128.110.1.255',2154692864,2154693119);
    3. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.4.0/22','/22','128.110.4.0','128.110.7.255',2154693632,2154694655);
    4. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.8.0/22','/22','128.110.8.0','128.110.11.255',2154694656,2154695679);
    5. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.12.0/22','/22','128.110.12.0','128.110.15.255',2154695680,2154696703);
    6. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.16.0/21','/21','128.110.16.0','128.110.23.255',2154696704,2154698751);
    7. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.16.0/22','/22','128.110.16.0','128.110.19.255',2154696704,2154697727);
    8. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.20.0/22','/22','128.110.20.0','128.110.23.255',2154697728,2154698751);
    9. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.24.0/22','/22','128.110.24.0','128.110.27.255',2154698752,2154699775);
    10. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.28.0/22','/22','128.110.28.0','128.110.31.255',2154699776,2154700799);
    11. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.28.0/24','/24','128.110.28.0','128.110.28.255',2154699776,2154700031);
    12. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.29.0/24','/24','128.110.29.0','128.110.29.255',2154700032,2154700287);
    13. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.30.0/24','/24','128.110.30.0','128.110.30.255',2154700288,2154700543);
    14. Insert into SUBNET_DECIMAL_VALS (subnet, CIDR_BLOCK, NETWORK, BROADCAST, NETWORK_DEC, BROADCAST_DEC) values ('128.110.31.0/24','/24','128.110.31.0','128.110.31.255',2154700544,2154700799);
    1. SELECT * FROM SUBNET_DECIMAL_VALS
    2. subnet cidr network network_dec broadcast_dec broadcast
    3. 128.110.0.0/20 20 128.110.0.0 128.110.15.255 2154692608 2154696703
    4. 128.110.1.0/24 24 128.110.1.0 128.110.1.255 2154692864 2154693119
    5. 22 128.110.4.0/22 128.110.4.0 128.110.7.255 2154693632 2154694655
    6. 22 128.110.8.0/22 128.110.8.0 128.110.11.255 2154694656 2154695679
    7. 22 128.110.12.0/22 128.110.12.0 128.110.15.255 2154695680 2154696703
    8. 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751
    9. 22 128.110.16.0/22 128.110.16.0 128.110.19.255 2154696704 2154697727
    10. 22 128.110.20.0/22 128.110.20.0 128.110.23.255 2154697728 2154698751
    11. 22 128.110.24.0/22 128.110.24.0 128.110.27.255 2154698752 2154699775
    12. 22 128.110.28.0/22 128.110.28.0 128.110.31.255 2154699776 2154700799
    13. 128.110.28.0/24 24 128.110.28.0 128.110.28.255 2154699776 2154700031
    14. 128.110.29.0/24 24 128.110.29.0 128.110.29.255 2154700032 2154700287
    15. 128.110.30.0/24 24 128.110.30.0 128.110.30.255 2154700288 2154700543
    16. 128.110.31.0/24 24 128.110.31.0 128.110.31.255 2154700544 2154700799

    What I tried to do is a hierarchical query traditional and used more than and less than the comparisons in the where clause

    . I'm trying to find the limits of subnet (top and bottom numbers) that match among other numerical limits. This is an example, and it gives me the results I need.

    1. Select the level, subnet, cidr_block cidr, broadcast network, network_dec, broadcast_dec
    2. of poc_subnet_decimal_vals
    3. nocycle to connect before network_dec > network_dec and broadcast_dec<>

    Do I have to create from this, it is something like this:

    1. Level of subnet CIDR network broadcast Network_Dec Broacast_Dec
    2. 1 20 128.110.0.0/20 128.110.0.0 128.110.15.255 2154692608 2154696703
    3. 2 128.110.1.0/24 24 128.110.1.0 128.110.1.255 2154692864 2154693119
    4. 2 128.110.4.0/22 22 128.110.4.0 128.110.7.255 2154693632 2154694655
    5. 2 128.110.8.0/22 22 128.110.8.0 128.110.11.255 2154694656 2154695679
    6. 2 128.110.12.0/22 22 128.110.12.0 128.110.15.255 2154695680 2154696703
    7. 1 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751
    8. 2 128.110.16.0/22 22 128.110.16.0 128.110.19.255 2154696704 2154697727
    9. 2 128.110.20.0/22 22 128.110.20.0 128.110.23.255 2154697728 2154698751
    10. 2 128.110.24.0/22 22 128.110.24.0 128.110.27.255 2154698752 2154699775
    11. 2 128.110.28.0/22 22 128.110.28.0 128.110.31.255 2154699776 2154700799
    12. 3 128.110.28.0/24 24 128.110.28.0 128.110.28.255 2154699776 2154700031
    13. 3 128.110.29.0/24 24 128.110.29.0 128.110.29.255 2154700032 2154700287
    14. 3 128.110.30.0/24 24 128.110.30.0 128.110.30.255 2154700288 2154700543
    15. 3 128.110.31.0/24 24 128.110.31.0 128.110.31.255 2154700544 2154700799

    Once, I get a hierarchical query of good work I can do the rest of the formatting with the values of the path and CYCLE but I'm not able to get a basic querying work. Does anyone have an idea of how to go on this subject using SQL only? I can write a PL/SQL procedure to add an ID of parent to each row, and then I know that I can create a hierarchical query from that but I was trying to avoid this method if possible.

    This is the right forum. I can see why there is only a single forum for SQL and PL/SQL, but I do not see why they suggest that there are separate forums.

    I'm not sure that you understand the problem.  In the ouptu (the line whose number 11) you have

    1. 2 128.110.28.0/22 22 128.110.28.0 128.110.31.255 2154699776 2154700799

    I guess this level = 2 means that the row is a child of a few rows, but which?  It was numbered line 7:

    1. 1 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751

    ?  This would mean that the child has a higher than its parent network_dec.

    I think you want something like this:

    WITH got_parent AS

    (

    SELECT s. *- or whatever the desired columns

    ,       (

    SELECT MIN (ss.subnet) DUNGEON (DENSE_RANK FIRST ORDER BY ss.broadcast_dec - ss.network_dec)

    OF subnet_decimal_vals ss

    WHERE ss.network_dec<=>

    AND ss.broadcast_dec > = s.broadcast_dec

    AND ss.subnet <> s.subnet

    ) As a parent

    OF s subnet_decimal_vals

    )

    SELECT LEVEL AS lvl

    subnet, cidr_block, network, broadcast, network_dec, broadcast_dec

    OF got_parent

    START WITH parent IS NULL

    Parent = subnet PRIOR CONNECTION

    ;

    The result is:

    LVL SUBNET NETWORK BROADCAST NETWORK_DEC BROADCAST_DEC CID

    --- ---------------- --- ---------------- ---------------- ----------- -------------

    1 20 128.110.0.0/20 128.110.0.0 128.110.15.255 2154692608 2154696703

    2 128.110.1.0/24 24 128.110.1.0 128.110.1.255 2154692864 2154693119

    2 128.110.4.0/22 22 128.110.4.0 128.110.7.255 2154693632 2154694655

    2 128.110.8.0/22 22 128.110.8.0 128.110.11.255 2154694656 2154695679

    2 128.110.12.0/22 22 128.110.12.0 128.110.15.255 2154695680 2154696703

    1 128.110.16.0/21 21 128.110.16.0 128.110.23.255 2154696704 2154698751

    2 128.110.16.0/22 22 128.110.16.0 128.110.19.255 2154696704 2154697727

    2 128.110.20.0/22 22 128.110.20.0 128.110.23.255 2154697728 2154698751

    1 22 128.110.24.0/22 128.110.24.0 128.110.27.255 2154698752 2154699775

    1 22 128.110.28.0/22 128.110.28.0 128.110.31.255 2154699776 2154700799

    2 128.110.28.0/24 24 128.110.28.0 128.110.28.255 2154699776 2154700031

    2 128.110.29.0/24 24 128.110.29.0 128.110.29.255 2154700032 2154700287

    2 128.110.30.0/24 24 128.110.30.0 128.110.30.255 2154700288 2154700543

    2 128.110.31.0/24 24 128.110.31.0 128.110.31.255 2154700544 2154700799

    Close enough to what you have requested, but not exact.  If this isn't what you want, explain how you can tell if a line is one ancestor of the other in the tree.

    I guess that this subnet is unique.  If this is not the case, the above query will have to be changed a little, but only a little.

Maybe you are looking for