using ' with in select ' to do a recursive query

Hello all dear
I have a question about ' with in select ' structure.
Is it possible to do a recursive query with this structure?

for example, this table (River: name, River, Lake, sea), I wrote this query to get all the rivers that flow directly or indirectly into a specific river:

Select the name of the RIVER r
Start with r.river = 'Zaire'
connect prior r.name = r.river
level control



now, how can I write the same function with ' with in select?

IM using oracle 11g.

If you need, I'll provide create/insert to the table.


best, david

Hello

This example gets the same results as searching for CONNECT BY you posted:

WITH     tree (name, lvl)  AS
(
     SELECT     name
     ,     1     AS lvl
     FROM     river
     WHERE     river     = 'Zaire'
    UNION ALL
        SELECT  r.name
     ,     t.lvl + 1
     FROM     river r
     JOIN     tree  t  ON     r.river     = t.name
)
SELECT       *
FROM       tree
ORDER BY  lvl, name
;

As you can see, the first part of the clause WITH recursive (the foregoing the UNION ALL) corresponds to the START WITH of a query CONNECT BY clause, and the second (after UNION ALL) corresponds to the CONNECT BY clause.

Tags: Database

Similar Questions

  • How to use the multiple selection list values in sql query

    Hi all
    In the search form, I have a multiselect llist tell (P3_STATUS) and I want to have a query using this element and fetch documents
    How to do a sql query based on the selection of the value of this element.
    SELECT "W"."START_DT" "Start Date",
           "W"."CAMPAIGN_CODE" "Campaign Name",  
           "W"."MKT_CHANNEL" "Channel",
           "W"."MKT_SUB_CHANNEL" "Sub Channel", 
           "W"."PROMO_CODE" "Promo Code",
           "W"."TRACKING_CODE" "Tracking Code",
           "W"."TFN" "TFN",
           "W"."STATUS" "Status",
           "W"."CAMPAIGN_CODE" "Edit"
           FROM 
             "WC_MKT_CAMPAIGN_DS" "W"
      
           WHERE 
         (MKT_CHANNEL = decode(:P1_CHANNEL,'%null%',MKT_CHANNEL,NULL,MKT_CHANNEL,:P1_CHANNEL))
       AND
    (MKT_SUB_CHANNEL= decode(:P1_SUB_CHANNEL,'%null%',MKT_SUB_CHANNEL,NULL,MKT_SUB_CHANNEL,:P1_SUB_CHANNEL))
    AND *STATUS = decode(.................*
    Please could someone help me on this?

    Thanks in advance
    Robert L

    Try to change your selection of status to

    AND INSTR(':'||:P3_STATUS||':',':'||STATUS||':') > 0
    
  • Select ambiguous column in Sub query

    I get an error "ambiguous column" when I question using a sub select. Here's my query:

    Select *.
    (select
    c.custody_id,
    c.person_id,
    n.first_name,
    n.last_name,
    z.usms_number,
    c.start_date,
    c.end_date,
    c.district_office_id,
    CBC.custody_id,
    c.update_date,
    c.update_user_id
    Guard c,.
    custody_booking_pkg_components Radio-Canada,
    z_migrate_usms_number z,
    district_office do,
    District d,
    person p,
    n name
    where
    c.person_id = p.person_id and
    z.person_id = p.person_id and
    z.Ordinal = 1 and
    c.custody_id = cbc.custody_id (+) and
    p.name_id = n.name_id and
    do.district_id = d.district_id and
    c.district_office_id = do.district_office_id and
    d.district_id = 99 by c.update_date desc order)
    where rownum < = 10;

    I understand why "ambiguous column" average error, but I don't see which column is ambiguous. I ran the select sub by itself and it works correctly, but when combined with the external selection it fails.

    Hello

    You have two columns called custody_id.
    It is normal to have names duplicated in a query, but not in a table or view (and which includes a view online, you have).

    Type a unique name for each column.

  • I can not open my Raw files from my new Nikon 810. With my Nikon 800 I use Bridge to select and then it opens to the PS CS5. To make it work with 810 I download the DNG Converter, but I still can't open the files.

    I can't open my Raw files from my new Nikon 810. With my Nikon 800 I use Bridge to select and then it opens to the PS CS5. To make it work with 810 I download the DNG Converter, but I still can't open the files. What can I do?

    Hi ulcabeek,

    Greetings!

    What version of DNG converter that you use?

    You need DNG converter 8.6 for this: 8.6 camera Raw and DNG Converter 8.6 now available

    Concerning

    Jitendra

  • I can not find, select, install the appropriate SR2 extended RAW for Phtoshop CS6 file to use with my Canon 5DSR camera... Please help

    I can not find, select, install the appropriate SR2 extended RAW for Phtoshop CS6 file to use with my Canon 5DSR camera... Please help

    Hi drdrum,

    Greetings!

    Update the software of camera raw as Canon 5DSR is supported camera raw version 9.0 and above.

    Here is the download link: https://helpx.adobe.com/x-productkb/multi/update-error-u43m1d204.html

    Also, here is the list that displays the camera with respective camera raw support:https://helpx.adobe.com/camera-raw/kb/camera-raw-plug-supported-cameras.html

    Concerning

    Jitendra

  • How to use the selection tool to resize a text box? Before I was able to click on the text box with the selection too in order to resize, but now I click on it and it only gives me 'path' or 'anchor' options.

    How to use the selection tool to resize a text box? Before I was able to click on the text box with the selection too in order to resize, but now I click on it and it only gives me 'path' or 'anchor' options.

    Ashley,

    What about window > show the rectangle enclosing (Ctrl / Cmd + Shift + B to toggle)?

  • White lines using the quick selection tool in conjunction with the Content Aware Fill.

    When you use the Quick Selection tool in conjunction with content aware fill I get a white line where is the join of the image.

    How can I stop this from happening?

    Basically, I need the tool select 'more select' in the next photo is a shame without welding.

    This isn't a complex selection, it's a photomerge with blank areas, white I'm filled out with content outside filling.

    Thanks for your help.

  • What Mac Mini for use with Adobe CC?

    Hello

    I thought about getting a Mac Mini to use with a Wacom Cintiq Display(either 22HD or 27QHD) and I was wondering what would be best for the execution of the Adobe programs.

    It seems that most of the people prefer the 2012 Mac mini with the quad core as opposed to the current gen using two hearts.

    This brings me to two questions:

    I see a huge difference between the quad core and dual core in the adobe programs?

    8 GB RAM is enough or should I opt for 16 GB?

    Otherwise, the mac mini may be a poor choice for what I would do, so any feedback is appreciated!

    Thank you!

    What Adobe suggest to their CC minimum specifications in OS X, it

    should not be necessary to buy a quad-core (they say that it would use all the cores).

    A set of Photoshop CC system requirements suggest higher specs than one

    Another help page for Adobe. This page shows the highest specifications, but can

    not reflect the version that you are considering:

    •Photoshop CC 2015.x system requirements and languages

    https://helpx.Adobe.com/Photoshop/system-requirements.html

    If for some reason you happen across a 2012 end i7 2.3 or 2.6 GHz quad with

    two 1 TB hard drives, they would be more easily upgraded to run an SSD and

    keep a rotating disc; or install two SSDs. between that and 16 GB of RAM, these

    should do a quick little computer. Rotational hard drives are the bottleneck.

    But probably not necessary for Adobe photoshop CC. The graphics processor

    is a limitation if you use intense graphic applications. GPU shares

    standard memory with the system; From memory, there is little or no dedicated graphics.

    Although I have a Late 2012 Mac Mini i7 2.3 GHz quad-core (server) with double 1 TB

    5400 RPM hard drive and RAM upgraded to 16 GB total rotation. It can

    Use at least one drive upgraded to 7200 rpm or SSD drive more efficient.

    The Mac Mini which is online store (check to see if there is an official refurb)

    in the middle to upper technical version may be OK. The top level because of the upgrade

    options in the configuration page (select to buy it, then see what options exist)

    might be OK. The lower spec Mini doesn't seem to be viable for serious users.

    New versions available now, because, you choose the configuration when

    you order the computer: you buy an upgrade level you think you might need.

    Memory is affixed, then exercise your ESP skills to look ahead, before buying.

    The new Mac Mini 'top model' has better graphics than model end 2012.

    An advantage for the Mini is you can choose monitors, peripherals, etc. An old

    new stock Mini would have some OS X who was active as a base level.

    Since none of these units have a system backup media. Is online recovery there.

    My Mini comes with the Mavericks 10.9; 10.9.5 functioning properly. Partitioned,

    the discs could dualboot mulitple systems and their applications more recent specifications.

    (You can pay like nine awards for the end of 2012 Mini i7 quad, used clean-shaped).

    I had considered to be a non - retina MacBook Pro 13 inch 2.5 GHz for once.

    It was the time when they were more common in the 'special offers' Apple

    refurb store page online at decent price; then buy RAM upgrade later.

    In any case, this has become a long rant a few detours or details were

    omitted for the sake of clear path back to the main topic. Since I was late

    2012, mac Mini and it's more of the half upgraded for most all that he can do

    I would probably say try a. If you can find a new one at a fair cost.

    If the cost is too high, you can get a new Mac Mini to higher specification

    the Apple Store. They are dual-core. Adobe applications do not seem to need

    the advantage of the use of quad-core processors or. (these run virtual cores, too;)

    so if you have the appropriate application, the quad core turn eight - virtual.)

    The option AppleCare extended warranty covers to buy new equipment.

    It would have supplied with El Capitan, if the current new stock. This fall, there may be macOS

    Sierra - if you happen to get that stock again - at the end of the year. Not sure

    If or when the hardware upgrade version configurations may appear.

    Anyway, it's more a kind of letter. Sorry about that...!

  • What version of firefox can I use with windows me?

    What version of Firefox can I use with windows me? Where can I get?

    The last version that worked with Windows Me was Firefox 2.0.0.20, you can get it from ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.20/win32/pt-PT/

    It's the same language you are using, if you need a different language, go to the top-level directory, and then select the folder for the language of your choice.

  • magnet mount accelerometers recommended by OR use with USB-4432

    Nice day!

    Are there recommended accelerometers by OR use with USB-4432. They should also be with magnet mounting option. I need reference numbers to select for general purpose applications.

    Thanks and greetings

    Try AND plug & play sensor Advisor

    http://sine.NI.com/apps/UTF8/NIPC.main?action=search_line&plid=1042

  • Error 907: This connection cannot be used with the VZAccess Manager

    original title: error message appear on my screen

    I get this error message appear on my screen every two seconds:
    "This connection cannot be used with the VZAccess Manager.

    Error 907 "

    Hello

    Disable/remove your Verizon Wireless software or contact Verizon for help with this error. Posts like this occur generally when third-party utilities are used to manage connections and issues must be resolved by the Distributor, because they are often specific to that software.

    Verizon support suggest that you go in the Options Internet/Control Panel and on the Connections tab, check the option "never establish a connection" is selected.

    Good luck, Rick Rogers, aka "Crazy" - Microsoft MVP http://mvp.support.microsoft.com Windows help - www.rickrogers.org

  • Get the error message, this button cannot be used with Windows Anytime Upgrade

    I just perchased a Windows Anytime Upgrade - Windows 7 Home Premium to Ultimate but when I enter the key I was send it tell me that this key can not be used with Windows Anytime Upgrade

    Windows 7 Anytime Upgrade fails:

    If your getting the following: error: Windows Anytime Upgrade failed
    This problem may occur if Windows 7 SP1 was downloaded by Windows Update, but has not yet been installed.
    See: http://support.microsoft.com/kb/2660811

    = Other reasons and possible corrections.

    Windows Anytime Upgrade fails with the error:
    "every time that the upgrade has failed. Go online to solve the problem.
    http://support.Microsoft.com/kb/2658652

    If Anytime Upgrade still does not work:

    Shut down and restart your computer.

    Make sure that the Windows updates have been installed.

    Download the hotfix that contains a tool called CheckSUR, this tool will look at the package and the maintenance of records and difficulty any data corrupted, the tool is listed under kb947821 he can be found at the following link http://support.microsoft.com/?kbid=947821

    If Anytime Upgrade still does not work, turn off the user account control:

    1. go in user accounts in Control Panel

    2 change user account control settings

    3. pull the slider to the level as low as possible

    4. restart the PC

    5. pass by the "Anytime Upgrade" as usual

    Try the following:

    1 disable any security software before attempting to upgrade

    2. make sure that your computer is updated (devices and applications)

    3. disconnect all external devices before installing.

    4. check your hard disk for errors:

    Click Start

    Type: CMD, according to the results, right-click CMD

    Click on "Run as Administrator"

    At the command prompt, type: chkdsk /f /r

    When you restart your system, your computer will be scanned for errors and will try to correct them.

    1. click on start, type msconfig in the search box and press ENTER.

    User account control permission

    If you are prompted for an administrator password or a confirmation, type the password, or click on continue.

    2. in the general tab, click Selective startup.

    3. under Selective startup, clear the check box load startup items.

    4. click on the Services tab, select the hide all Microsoft Services check box, and then click Disable all.

    5. click on OK.

    6. When you are prompted, click on restart.

    7. after the computer starts, check if the problem is resolved.

    Also run the Windows 7 Upgrade Advisor:

    http://www.Microsoft.com/Windows/Windows-7/Upgrade-Advisor.aspx

    Who should I contact if I have problems installing and / or activation of my product key card?

    Please contact to the: www.windows7.com/getkeysupport.

    If all above fails them, install Windows 7 Service Pack 1, and then try the Express Upgrade:

    Learn how to install Windows 7 Service Pack 1 (SP1)
    http://Windows.Microsoft.com/en-us/Windows7/learn-how-to-install-Windows-7-Service-Pack-1-SP1

    If your key is not valid and you will need to change the keys, you may need to Open regedit and remove first the ProductKey value in the following registry key:
     
    HKCU\Software\Microsoft\Windows\CurrentVersion\WindowsAnytimeUpgrade

  • Use with need to collect in bulk to insert records from multiple tables

    Hello

    I plsql record type with several tables with multiple columns. so when I used bulk collect with education for ALL. I want to insert records in multiple tables.

    Please give me suggestions.

    ForAll is designed to be used with a single DML statement, which may include dynamic SQL statements. However, I do not know what advantage this will give you your list iteration save several times, one for each table - especially since there is an air show with SQL dynamic.

    Example 1 (dynamic SQL):

    begin

      ...

      forall i in vRecList.First..vRecList.Last
        execute immediate '
        begin
          insert into Table1 (Col1, Col2, Col3) values (:1, :2, :3);
          insert into Table2 (Col1, Col2, Col3) values (:1, :2, :3);
        end;' using vRecList(i).Col1, vRecList(i).Col2, vRecList(i).Col3;
    end;

    Another approach that I should work (but not tested) is using to insert all the Scriptures and based record inserts, but you need to try on your version of Oracle forall has changed between the versions.  In this case vRecList must be compatible with the Table % ROWTYPE and Table2% ROWTYPE type.


    Example 2 (insert all):

    begin

      ...

      forall i in vRecList.First..vRecList.Last

        insert all

          into Table1 values vRecList(i)
          into Table2 values vRecList(i)
        select 1 from dual;

    end;

  • Case statement with a select &amp; date in

    Hello everyone,

    This is my first discussion, so please bare with me.

    I am trying to write a case statement with a select statement that compares the dates.

    When I write an instruction box with a select statement in it compares everything but dates it works fine.  Once the date is there, he collapses.

    Here is a super simple example of what I'm trying to do, "b.in_serv_dt" is a date

    Select unit_no,

    case when ((sélectionnez b.in_serv_dt de b unit_dept_comp_main où a.unit_id = b.unit_id et b.in_serv_dt) > = 1 January 2012 "") then "everybody wins."

    When ((sélectionnez b.in_serv_dt dans l'unit_dept_comp_main b où a.unit_id = b.unit_id et b.in_serv_dt) < = 1 January 2012 "") then "Nobody wins".

    end

    of ottawa_unitmain_v one

    Any help would be greatly appreciated

    Thank you very much

    Hello

    your statement of formatting:

    Select unit_no
    case when ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    and b.in_serv_dt
    ") > = JANUARY 1, 2012"
    ) and then "everybody wins."
    When ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    and b.in_serv_dt
    )<=>
    ) and then "no winner".
    end
    of ottawa_unitmain_v one

    I see "partial conditions": <... and="" b.in_serv_dt="">> that have no meaning.
    I guess it's a kind of "typo" and I ignore them.
    If the statement is:
    Select unit_no
    case when ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    ") > = JANUARY 1, 2012"
    ) and then "everybody wins."
    When ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    )<=>
    ) and then "no winner".
    end
    of ottawa_unitmain_v one

    I guess that the "b select" retrieve one line, through the design of database (forced...)

    As already written: be careful with data types: avoid "implicit conversions" (when you compare different data types, Oracle has convert the data type of the other side, a side example: "mystring = mynumber" is transformed into 'TO_NUMBER (mystring) = mynumber', or 'mydate = mystring' translates mydate = TO_DATE (mystring, ) ")
    Even better: use explicit conversions, use explicit formats when necessary.
    Best: use no conversion on columns from the constants, but use the correct data type for the constant.

    With this in mind:
    Select unit_no
    case when ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    ) > DATE = ' 2012-01-01'
    ) and then "everybody wins."
    When ((select b.in_serv_dt
    of unit_dept_comp_main b
    where a.unit_id = b.unit_id
    )<= date="">
    ) and then "no winner".
    end
    of ottawa_unitmain_v one
    But note that b.in_serv_dt EQUAL to 1 January 2012 (at 00:00:00) is OK for both WHEN the conditions; then the a "win."

    Now: the subselect statement is identical in the 2 options of the case... You could work differently: (I add the "ELSE" in case one line as NULL in_serv_dt;) I guess that an INNER JOIN is OK, maybe you need a LEFT OUTER JOIN (if some lines of A have no corresponding row in B)

    SELECT a.unit_no
    , CASE WHEN b.in_serv_dt > = DATE '' 2012-01-01
    THEN "everyone wins"
    WHEN b.in_serv_dt< date="">
    While "Nobody wins".
    ELSE ' who knows... ". »
    END who_wins
    Of ottawa_unitmain_v one
    INNER JOIN unit_dept_comp_main b
    ON a.unit_id = b.unit_id
    ;

    Best regards

    Bruno Vroman

  • Adobe creative suite 4 design premium oem can it be installed and used with windows 7

    can adobe creative suite 4 design premium oem be installed and used with windows 7

    I think that CS4 was written for Windows XP, the only way you will know is to see if the installation works for you

    You may need to right-click on the EXE and select Windows XP compatibility mode in the options window

Maybe you are looking for