Queries line to generate a tree for a given node value

Hello

I have a requirement where I want to fill a tree only the filling of the structure that contains a given value.

For example the complete structure for the emp table is
PATH

-> SCOTT
-> SCOTT-> ADAMS
-> FORD
--> FORD--> SMITH
-> ALLEN
-> JAMES
-> TURNER
-> MARTIN
-> WARD
--> MILLER
-> ADAMS
-> JONES
-> JONES-> SCOTT
-> JONES-SCOTT-> ADAMS >
-> JONES-> FORD
-> JONES--> FORD--> SMITH
-> CLARK
-> CLARK-> MILLER
-> BLAKE
-> BLAKE-> ALLEN
-> BLAKE-> JAMES
-> BLAKE-> TURNER
-> BLAKE-> MARTIN
-> BLAKE-> WARD
-> SMITH
-> KING
-> KING-> JONES
-> KING->-> SCOTT JONES
-> KING->->-> ADAMS SCOTT JONES
-> KING-JONES-> FORD >
-> KING-JONES--> FORD--> SMITH >
-> KING-> CLARK
-> KING-CLARK-MILLER > >
-> KING-> BLAKE
-> KING->-> ALLEN BLAKE
-> KING->-> JAMES BLAKE
-> KING-BLAKE-TURNER > >
-> KING-BLAKE-MARTIN > >
-> KING-> BLAKE-> WARD

and I need only records that has SCOTT, would be the expected production
-> SCOTT
-> SCOTT-> ADAMS
-> JONES-> SCOTT
-> JONES-SCOTT-> ADAMS >
-> KING->-> SCOTT JONES
-> KING->->-> ADAMS SCOTT JONES

How can this be achieved. Any help will be appreciated.

To go faster, create an index on ENAME, then:

with emps_up as (
  select EMPNO, MGR from EMP
  start with ename = 'SCOTT'
  connect by MGR = prior EMPNO
), EMPS_DOWN as (
  select EMPNO, MGR from EMP
  where level > 1
  start with ename = 'SCOTT'
  connect by EMPNO = prior MGR
)
select substr(SYS_CONNECT_BY_PATH(ENAME, '->'), 3) ename_path
from (
  select * from EMPS_UP
  union all
  select * from EMPS_DOWN
) a join EMP B on a.EMPNO = B.EMPNO
where connect_by_isleaf = 1
start with a.MGR is null
connect by a.mgr = prior a.empno;

KING->JONES->SCOTT->ADAMS

I don't know why you want to repeat the intermediate lines. If this is really necessary, just change the last WHERE clause.

P.S. You say you want to use the LIKE clause, because your table is huge. You don't want to omit the START WITH. The TYPE would be OK if there is any '%' in the beginning.

Published by: stew Ashton on 29 August 2012 23:04

Tags: Database

Similar Questions

  • for any given initial value error message

    Hello experts,

    I created a form with the period_type as a drop-down list and do not specify an initial value. But I have this warning msg. How can I get rid of that?

    FRM-30188: no given initial value and other values are not allowed (point EFT_PERIOD. PERIOD_TYPE).
    List PERIOD_TYPE
    Block: EFT_PERIOD

    Thank you

    Open the mouth of property for this EFT_PERIOD article. PERIOD_TYPE and property in the LIST ITEM just remove the value of handguns as well as the return value for the first value, then compile the form.

    First value will be like LIST123 just delete this value and then try...

    -Clément

  • SQL query to search for the line that contains the identifier for each consecutive group

    Hello

    I'm on 11.2.0.3 Enterprise Edition.

    I have a strange request here - do not know if this is possible without going to procedure...

    Given these data of the sample:

    create table test_status (
      status varchar2(10),
      revision_id number,
      revision_timestamp timestamp);
    
    insert into test_status values ('PROPOSED', 1, systimestamp);
    insert into test_status values ('PROPOSED', 2, systimestamp);
    insert into test_status values ('PROPOSED', 3, systimestamp);
    insert into test_status values ('ACTIVE', 4, systimestamp);
    insert into test_status values ('ACTIVE', 5, systimestamp);
    insert into test_status values ('PROPOSED', 6, systimestamp);
    insert into test_status values ('PROPOSED', 7, systimestamp);
    insert into test_status values ('ACTIVE', 8, systimestamp);
    insert into test_status values ('ACTIVE', 9, systimestamp);
    insert into test_status values ('FINISHED', 10, systimestamp);
    insert into test_status values ('FINISHED', 11, systimestamp);
    insert into test_status values ('FINISHED', 12, systimestamp);
    

    Gives me:

    SQL> select *
      2  from test_status
      3  order by revision_id;
    
    
    STATUS     REVISION_ID REVISION_TIMESTAMP
    ---------- ----------- -----------------------------
    PROPOSED             1 25-SEP-14 04.49.47.954000 PM
    PROPOSED             2 25-SEP-14 04.49.47.962000 PM
    PROPOSED             3 25-SEP-14 04.49.47.966000 PM
    ACTIVE               4 25-SEP-14 04.49.47.969000 PM
    ACTIVE               5 25-SEP-14 04.49.47.972000 PM
    PROPOSED             6 25-SEP-14 04.49.47.976000 PM
    PROPOSED             7 25-SEP-14 04.49.47.979000 PM
    ACTIVE               8 25-SEP-14 04.49.47.982000 PM
    ACTIVE               9 25-SEP-14 04.49.47.987000 PM
    FINISHED            10 25-SEP-14 04.49.47.991000 PM
    FINISHED            11 25-SEP-14 04.49.47.996000 PM
    FINISHED            12 25-SEP-14 04.49.48.000000 PM
    
    
    12 rows selected.
    ws selected.
    

    I want to get this result:

    STATUS     REVISION_ID REVISION_TIMESTAMP
    ---------- ----------- ----------------------------
    PROPOSED             3 25-SEP-14 04.49.47.966000 PM
    ACTIVE               5 25-SEP-14 04.49.47.972000 PM
    PROPOSED             7 25-SEP-14 04.49.47.979000 PM
    ACTIVE               9 25-SEP-14 04.49.47.987000 PM
    FINISHED            12 25-SEP-14 04.49.48.000000 PM
    

    Then query the table ordered by Revision_Id, I would get the line containing the highest revision for each consecutive group of status values.  I am able to get the line containing the highest revision for each separate status, value, but I can't deal with the scenario where a state value reappears later.  In the case of the real world, it is a workflow and I need to take into account the fact that an element through the workflow may be redirected to the back front she proceeds forward again.

    Hope it makes sense.

    Thank you

    John

    Hi, John,.

    John OToole (Dublin) wrote:

    Hello

    I'm on 11.2.0.3 Enterprise Edition.

    I have a strange request here - do not know if this is possible without going to procedure...

    ...

    Do not no stinkin' procedure:

    WITH got_grp_id AS

    (

    SELECT the status, revision_id, revision_timestamp

    ROW_NUMBER () OVER (ORDER BY revision_id)

    -ROW_NUMBER () (PARTITION STATUS

    ORDER BY revision_id

    ) AS grp_id

    OF test_status

    )

    SELECT status

    MAX (revision_id) AS revision_id

    MAX (revision_timestamp) DUNGEON (DENSE_RANK LAST ORDER BY revision_id)

    AS revision_timestamp

    OF got_grp_id

    GROUP BY status, grp_id

    ORDER BY revision_id

    ;

    For an explanation of the technique of Difference sets used here, see

    Analytic Question lag and lead and/or

    Re: Ranking of queries

  • Impossible to uninstall a program error: unable to generate the uninstaller for ca aintivirus E9030 command line.

    Original title: impossible to uninstall the program error msg

    I'm unable to uninstall a program, an error message keeps popping up saying "error E9030 cannot generate the uninstaller for ca aintivirus command line.
    can anyone help?

    Original title: impossible to uninstall the program error msg

    I'm unable to uninstall a program, an error message keeps popping up saying "error E9030 cannot generate the uninstaller for ca aintivirus command line.
    can anyone help?

    Try this... no guarantee

    Start > computer > open C: drive > open the Progran files > y at - it a record of the Ca antivirus?
    If so, open it > is there a uninstaller.exe file here?
    If so, open it and let go about uninstalling.

    Or,

    Start > all programs > CA antivirus > y at - it an option to uninstall?

    Hope one of these AIDS.

  • not generating the trace for rdf report by oracle apps file

    Hi all


    in fact, we aim to generate trace file for reports and a convert to text file using tkprof by simultaneous program unix shell script submit using fnd_request.submit_request in another program of concurrent proceedings. but all the reports that are created by using pl/sql generates the trace file, but rdf report does not trace file.

    Report generator Oracle 6i is used

    Oracle application is 11i

    List of measures are being taken to get the trace file are
    1.SRW. USER_EXIT (' FND SRWINIT' "); before the release of report
    2SRW. USER_EXIT ("FND SRWEXIT'"); in after the report

    another of the measures which are followed
    SRW.do_sql ("alter session set SQL_TRACE = TRUE'"); before release of the report
    SRW.do_sql ("alter session set SQL_TRACE = FALSE'"); in after the report

    above, said steps are done, but still it does not arouse any trace file

    same oracle_process is null

    Select oracle_process_id from the fnd_concurrent_requests where request_id

    ID processOracle for this report oracle rdf file is not generated.


    Please help me in this issue

    Thank you

    Published by: 797525 on October 12, 2012 12:43 AM

    Add the following line before the outbreak of report
    SRW. DO_SQL ("alter session set events = tracefile_identifier" trace 10046 name context forever, level 4 "=" REPORT ' ")

    Trace stops automatically when the report closes.

    In addition, what program submits the script fnd_request.submit_request... shell / pl/sql procedure?

    you initialize apps FND_GLOBAL. APPS_INITIALIZE before submit_request of shooting?

    Make a DNF: active Log Debug = Yes and check the table of fnd_log_messages

    See the following MOS docs:
    Oracle 6i [ID 111311.1] follow-up reports
    See you soon,.
    ND
    Use the buttons "useful" or "correct" to award points to the answers.

  • Generate output XML for a PL/SQL stored procedure concurrent program (EBS).

    Hello

    I trying to generate XML output for a simultaneous PL/SQL program and then use it as a model for BEEP.
    Program PL/SQL for a report consist of sliders/queries and other calculations of output data.
    Program (report) made up of topics, couple of col. values of one or more tables DB and rest of the columns are values read from DB colonel and calculated. The length of the neck extends up to 280 characters.

    All out - put is shown using fnd_file.put_line (fnd_file.ouput,...);
    before first fnd_file statement, included the following stmt.
    fnd_file.put_line (fnd_file.output,' <? xml version = "1.0" encoding = "UTF - 8"? > ');

    Using demand conc., notice ouptut poster error...
    The XML page cannot be displayed
    Invalid at the top level of the document. Error during processing of the resources ' http://ohcol0ws023.amp-ohio.org:8004/OA_CGI/FNDWRR.exe...
    <? XML version = "1.0" encoding = "UTF-8"? >

    I tried to add tags in the rest of the fnd_file.put_line stmts. as
    fnd_file.put_line (fnd_file.output, '< Heading1 >' |) 'Report name ' | (/ head2 > '); etc.

    View output shows the same error message.

    PL. advise how go further or tell me the link, if it's already been answered earlier.

    Thank you
    Prak

    Copy the file from $APPLCSF / $APPLOUT to your customer and try to open it. Find out what's wrong with the code XML, for example, you may need to top level element:

    Write to me if you can't get by - see my profile.

    Kind regards
    Gareth

  • Make an adjustment in line with the Vision Assistant for a polynomial function?

    Hello

    I have the following problem: I have a laser beam which a (non-linear) line on a wall. For this line, I need to know (exactly) mathematical

    function. That's why I can get a picture of the line, but I don't know how I can extract the mathematical function with a line fit for example. If I could "convert."

    the line at points that I would use the line fit function to LabView that should work without problem.

    Is there a way to solve the problem with vision assistant or... ?

    Thanks in advance

    Hello

    after thresholding, this should work:

    False case just by...

    Best regards

    K

  • write 1 d digital table in a binary file and start a new line or insert a separator for each loop writing file

    Hello:

    I'm fighting with digital table of 1 d writeing in a binary file and start a new line or insert a separator for each loop writing file. So for each loop, it runs, LABVIEW code will collect a table 1 d with 253 pieces of a spectrometer. When I write these tables in the binay file and the following stack just after the previous table (I used MATLAB read binary file). However whenever if there is missing data point, the entire table is shifted. So I would save that table 1-d to N - D array and N is how many times the loop executes.

    I'm not very familiar with how write binary IO files works? Can anyone help figure this? I tried to use the file position, but this feature is only for writing string to Bodet. But I really want to write 1 d digital table in N - D array. How can I do that.

    Thanks in advance

    lawsberry_pi wrote:

    So, how can I not do the addition of a length at the beginning of each entry? Is it possible to do?

    On top of the binary file write is a Boolean entry called ' Prepend/chain on size table (T) '.  It is default to TRUE.  Set it to false.

    Also, be aware that Matlab like Little Endian in LabVIEW by default Big Endian.  If you probably set your "endianness" on writing binary file as well.

  • Generate SNMP traps for monitoring tests

    Hi all

    We would like to test our network management system effectively.

    We have configured SNMP. But as we cannot generate some breakdowns that we want to generate some test traps.

    Could you tell me if there is a way to generate the CLI for i.e. false SNMP traps?

    Ideally, we would like to test things like: excess temperature, the FAN failure, failure of power, etc...

    Any help would be appreciated,

    Thank you very much in advance

    Concerning

    Sorry I see you wanted traps, not sys records my bad, so try this link https://supportforums.cisco.com/docs/DOC-11745

    Sent by Cisco Support technique iPad App

  • generates keys option for VCS and VCSE cisco

    Hello team,

    How we generate option keys for cisco VCS and example VCSE under keys of the cisco site.

    LIC-VCS-10 Video server Comm 10 Add Non-traversal network calls

    Thank you

    Renji

    Hi Renji.

    If you have already purchased the license and then click on the following link and re build.

    https://Tools.Cisco.com/swift/LicensingUI/tandbergLicenseLookup

    If it is not purchased then contact your account key to Cisco for new purchase Manager.

    HTH

    Kind regards

    Dharmmesh

  • PowerCli script to generate the report for the VM and ESXi model

    Hello

    I'm trying to generate a report for the virtual machines to a domain controller that includes the operating system, Cluster and host of brand and model of ESXi, but for some reason any the ESXi info does not come through. Any help is greatly appreciated.

    Get-data center 'TEST ' |

    Get - vm |

    WHERE-object {$_.} PowerState - eq "Receptor"} |

    Select Name, @{N = "OS"; e = {$_.}} Extensiondata.Guest.GuestFullName}},

    @{N = "Cluster"; E={$_. VMHost.Parent}},

    @{N = 'Esxi model'; E = {Get-VMHost - VM $_.} VM | {{Select model}}

    The virtual machine has the properties of the host.  For your information "Model ESXi" use $_. VMhost.Model, $_ is the current information for pipeline for the virtual machine.  You did for the section "cluster".

  • How can I generate a url for a PDF link?

    I'm trying to generate a url for a PDF link. Any suggestions?

    You can download your PDF on cloud.acrobat.com, then use the service of the runway show & to create an anonymous link to it.

    See: Document Cloud help | Manage files

  • Generate public names for all attributes?

    Hi all

    What suggestions do you generate public names for all attributes in OPM 10.4?

    We try to the pretty square of the record of decision by setting invisible all attributes, except for: the goal first, structural reference number and database.

    Looks like the only way to do is to go in the model of generation and manually create the public name one by one.

    Thank you

    Isamu

    Unfortunately, you are right and it is difficult to create public names for intermediate attribute as a bulk operation.

    You can retrieve the part of how to compile each document in turn, and then by creating public names for the document and then remove the xgen before moving on to the next-, but this will not help you with the attributes that are intermediate in the document rules - but it will get you the way which (unfortunately I see you want to keep the legal references, so if you use structural elements that mean that by they) are intermediate in their own documents).

    Another common technique is that when there is common text used in different segments that you create a public file names of model for this * all * attributes and make a copy of the model, then do a search and replace (in a text editing tool). That has been my main approach on projects where I need to give intermediate attributes a public name - it is absolutely vital to the attribute naming conventions right (and is often what you get taken into account from the design of modules - so a little more difficult to retro-actively to implement).

  • How to generate the code for the ZXP file signing certificate

    I'm developing a creative using FlashBuilder 4.6 Adobe extension. I released the extension of a file .zxp and wanted to generate the code for him signing certificate. I've checked all the supported providers Adobe, but not found that anyone can do. Only, they provide the certificate for *.exe * .cab, *.dll and *.ocx.


    Thanks in advance.

    Leon.

    It's all too confusing.

    We use the Comodo certificate. You can use all the others as long as you end up with a point p12 certificate.

    Signing certificate by using the Digital Signature of the code

    http://www.InstantSSL.com/code-signing/index.html

    (1) request you the certificate. I used Internet Explorer on a PC because Comodo says it's better for them.

    (2) they do a thorough credit check to make sure that you are who you claim to be.

    (3) they shall issue a certificate giving you a PIN that he pay back.

    (4) redeem you your PIN certificate and the certificate is in your browser certificate cache.

    (5) you go to the cache and add a personal password for your certificate.

    (6) what makes a dot P12 file file name you choose.

    (7) now you can use your file p12 point with the utilities Adobe XZPSignCmd or ucf.jar to sign your Panel. I use the Mac utilities to sign on a Mac. The point p12 file is good on the PC and Mac.

    Don't worry, the utilities they speak about to sign. Adobe has their own utilities ZXPSignCmd and ucf.jar to do the signature. You are forced to timestamp your signature.

  • Generate public names for intermediate values?

    I'm trying to remember, but I can't find the reference.

    To configure the properties for the web service file, is it necessary to have public names for the intermediate attributes or conclusions? (I remember that the answer is Yes... and which would make sense).

    If the answer is Yes, is there a trick to generate public names for all attributes and not only the basic level? (I think that the answer is no.)

    If my memory is good, can someone explain the logic do not provide a checkbox to generate all the attributes?

    Thank you

    Hi Paul,.

    I do not think that necessary add public names for all intermediaries; the ODS compatibility check when you generate in OPM search only public names for top-level attributes and base level.

    However here in Sweden, we have made a decision to give each attribute public names (Basic, intermediate and senior), because the integration and test teams may want to check the value of a rule using ODS. It is really useful for OPM unit tests and the etc test results - even when text attribute changes, we do not have update the test script since the public name is there and she had remained the same... It is also our final report of the decision and generally easier to follow other OPM reports.

    I know that some projects don't want to do it as they see it as more maintenance, but we have a here useful naming convention and the benefits of having intermediate public names outweighed the small effort necessary to keep them up-to-date.

    I don't think that there is a quick way to generate automatically the intermediate public names unfortunately... we just added them little by little since the beginning of the project. If you have literally 1000s to add, it can be faster to add a properties file in generating the XML yourself. I like to use Excel to generate a properties file when I have a collective update or addition make.

    I hope this helps! ID be interested in other ways to add all intermediaries, if others have them!

    See you soon,.
    Ben

Maybe you are looking for

  • When will release the new version of iOS 9.3?

    Hello My iPad 4 has downloaded the update iOS 9.3, but I am unable to verify the update since Apple stopped signing the update temporarily due to a bug of activation. I was just wondering if the new iOS version 9.3 was released for iPad 4 and how to

  • Error in Windows Live Mail: "this application has requested execution to terminate in an unusual way.

    Occasionally, the following message appears when my wife receives an email from someone on facebook. "This application has requested execution to terminate in an unusual way" launches us live mail. It has something to do with Microsoft Visual C ++ Ru

  • How to: restore to factory specifications.

    Original title: how to reformat the computer hp laptop without os cd I want to reformat my computer hp laptop to how it was when I bought it first but the problem is that I don't have a CD of windows vista operating system when I got the laptop, so I

  • L7680 JO is no longer on the network

    I have a L7680 all-in-One, since this model is released - I think about 10 years.  It's a great printer.  Suddenly, he "fell off" my network, and I can't put it back on. I use a wired Linksys Cisco network and the printer must receive its IP from the

  • Storm more unwanted signs in the search box and the password box

    Dear friends recently my computer gives me following problem. Sometimes the password box when I try to log in as an administrator, start to fill up with points. In case I start browsing with IE, the address bar starts to automatically fill with "more