query regarding link by

I have the following table, named student: -.


NAME
--------------------
one
b
c
d

Now, I stumbled upon a clause connect by but I can't understand how it works. I know this has something to do with the treelike structures. But when I issued the following query:
Select * student connect you prior name > name;
-the following report was produced: -.



NAME
--------------------
one
b
one
c
one
b
one
d
one
b
one

NAME
--------------------
c
one
b
one

15 selected lines.



I really don't understand how it works. Help, please.
Thanks in advance

Published by: user11930797 on April 27, 2010 05:02

Published by: user11930797 on April 27, 2010 05:03

Published by: user11930797 on April 27, 2010 05:04

Maybe it help if you choose the level and the full path, like this:

SQL> with student as
  2  ( select 'a' name from dual union all
  3    select 'b' from dual union all
  4    select 'c' from dual union all
  5    select 'd' from dual
  6  )
  7   select name
  8        , level
  9        , sys_connect_by_path(name,' --> ') scbp
 10     from student
 11  connect by prior name > name
 12  /

N      LEVEL SCBP
- ---------- --------------------------------------------------
a          1  --> a
b          1  --> b
a          2  --> b --> a
c          1  --> c
a          2  --> c --> a
b          2  --> c --> b
a          3  --> c --> b --> a
d          1  --> d
a          2  --> d --> a
b          2  --> d --> b
a          3  --> d --> b --> a
c          2  --> d --> c
a          3  --> d --> c --> a
b          3  --> d --> c --> b
a          4  --> d --> c --> b --> a

15 rows selected.

Now, it shows that you generate 4 trees. One for each record, because there is no clause "begins by" specified. And then the tree is constructed using the clause "previous name > name", hence this exit.

I hope this helps.

Kind regards
Rob.

Tags: Database

Similar Questions

  • A query regarding the creation of shared objects.

    Hello

    I have a query regarding the creation of shared objects.

    I saw an example where the author is creatining Shared Object as shown
    below:


    SharedObj = null;
    sharedObj = SharedObject.getLocal ("myTasks");

    and there is nothing related to the word "myTasks" anywhere in the Application.

    Can someone please let me know what this word "myTasks" mean here?

    Thanks in advance.

    Hello

    With a shared object, it will create one if it does not exist, then "myTasks" becomes the name of the shared object or if it exists it will load all the objects that are in the shared object.

    Here is a simple example that uses the sharedobjects to store the connection information.

    http://gumbo.flashhub.NET/login/

    David

  • Regarding link usage reports

    Hi all

    I did install Whatsup gold version no 11 to monitor the network and Server devices. My request is Internet link im not able to get reports even if I do not know how to set up the router for the link usage reports and you need to configure the router to enable this Service. Kindly help me to achieve this challenge.

    Fauchon

    Hi All,

    I have installed Whatsup gold version no 11 to Monitor Network as well as Server devices. My query is im not able get Internet link reports even i don't know how to configure Router to get Link Utilization Reports and what need to configure on router to enable this Service. Kindly help me to achive this Challenge.

    Farook

    Fauchon,

    You must configure the ip address of the snmp (which is gold) server in the router with community sting that is configured as a server. Go to the link for guide to site amenities whatsup gold for help below!

    http://docs.Ipswitch.com/nm/87_WhatsUp%20Gold%20v14.1/02_Guides/WhatsUp%20Gold%20v14.1%20Getting%20Started%20Guide.PDF

    Hope to help!

    Ganesh.H

    Don't forget to note the useful message

  • Query regarding to_date for special requirements

    Hi all

    We have a purge script that should be run every day at 03:00 on the oracle database. This script deletes data for the duration of 22:00 to 03:00.

    This is the part of query that specifies the duration.

    Could you please suggest how to change to_date so that created_time meets our requirement.

    ( String getMessageGroupIds = «SELECT Group_id FROM MEDIATOR_INSTANCE WHERE COMPONENT_STATE IN ('4', '7') and created_time > = to_date (6 August 2013 13:55 ",)" MM/DD/YYYY HH24:MI:SS') and created_time < = to_date (6 August 2013 15:55 "," MM/DD/YYYY HH24:MI:SS') and the name of the component as '% default/UpdateSalesOrderOSMCFSCommsJMSConsumer%' ';

    Thank you and best regards,

    Bob

    912286 wrote:

    Hi Marty/Etbin,

    I tried to request below:

    String getMessageGroupIds = ' SELECT Group_id FROM MEDIATOR_INSTANCE WHERE COMPONENT_STATE IN ('4 ', ' 7') and created_time > = to_date (TRUNC (SYSDATE-1) + 22 / 24) and created_time.<= to_date(trunc="" (sysdate)="" +="" 3="" 24="">

    but it does not give the result desired, rather, it is the outcome of sysdate-1 to sysdate and countless hours.

    TIA,

    Bob

    you use to_date on the date data type

    String getMessageGroupIds = ' SELECT Group_id FROM MEDIATOR_INSTANCE WHERE COMPONENT_STATE IN ('4 ', ' 7') and created_time > = TRUNC (SYSDATE-1) + 22 / 24 and created_time.<= trunc="" (sysdate)="" +="" 3="">

    Concerning

    Etbin

  • Query using link help?

    I'm quite new in the world of SQL and I'm having a problem with an application using binding. I use SQL Developer (3.1.07).
    If I run the query with no binding, everything works fine. Normal occasions I have run this query on the day I want my totals and I get my desired results:

    HIS SELECTION. CRAFTS, nvl (SUM (SA. (LABORHRS), 0) ' loaded hours. "
    SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE ON SB SB. BASELINEID = SA. BASELINEID
    WHERE SB. DATECODE = "DAILY".
    AND TO_CHAR (SB. FROMDATE, "MON-DD-YYYY") = TO_CHAR (SYSDATE, ' DD-MON-YYYY "")
    AND TO_CHAR (SB. TODATE, 'DD-MON-YYYY') = TO_CHAR (SYSDATE, ' DD-MON-YYYY "")
    AND TO_CHAR (SA. SCHEDULEDATE, "MON-DD-YYYY") = TO_CHAR (SYSDATE, ' DD-MON-YYYY "")
    Sa.craft group
    sa.craft asc order

    BOATS loaded hours
    ---------- -------------------
    CONTROL.     24
    12 MM
    MT 6


    BUT * I want to enter my own date rather than use sysdate. This will be for when I get bored of running this for a day, wonder for the values of an earlier date, etc...
    The value will always be the same for all three date fields (SB. FROMDATE, SB. TO DATE, SA. SCHEDULEDATE)
    I modified the request here and the query still works very well at this stage: (I use April 1, 2012 to my link...)

    HIS SELECTION. CRAFTS, nvl (SUM (SA. (LABORHRS), 0) ' loaded hours. "
    SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE ON SB SB. BASELINEID = SA. BASELINEID
    WHERE SB. DATECODE = "DAILY".
    AND SB. FROMDATE =: DDMONYYYY
    AND SB. TODATE =: DDMONYYYY
    AND TO_CHAR (SA. SCHEDULEDATE, "MON-DD-YYYY") = TO_CHAR (SYSDATE, ' DD-MON-YYYY "")
    Sa.craft group
    sa.craft asc order

    BOATS loaded hours
    ---------- -------------------
    CONTROL.     24
    12 MM
    MT 6

    Now I change my request to what follows, I get a different result:

    HIS SELECTION. CRAFTS, nvl (SUM (SA. (LABORHRS), 0) ' loaded hours. "
    SOL_SCHEDULEBASELINEWOASGMNT SA
    LEFT JOIN SOL_SCHEDULEBASELINE ON SB SB. BASELINEID = SA. BASELINEID
    WHERE SB. DATECODE = "DAILY".
    AND SB. FROMDATE =: DDMONYYYY
    AND SB. TODATE =: DDMONYYYY
    AND SA. SCHEDULEDATE =: DDMONYYYY
    Sa.craft group
    sa.craft asc order

    BOATS loaded hours
    ----------- ------------------
    CONTROL.     10

    All columns have a Date data_type.
    As soon as I change SA. SCHEDULEDATE of

    AND TO_CHAR (SA. SCHEDULEDATE, "MON-DD-YYYY") = TO_CHAR (SYSDATE, ' DD-MON-YYYY "")

    TO

    PAM SCHEDULEDATE =: DDMMYYYY

    He keeps the results I need back.

    Why is this? Does anyone have an idea of what's going on here? Any help would be GREATLY appreciated!
    Thank you

    Hello

    Welcome to the forum!

    I'm not very familiar with SQL Developer. Should bind variables DATE? Other Oracle products; in them, you must use VARCHAR2 variables, like this (which works in SQL * more):

    VARIABLE  ddmonyyyy     VARCHAR2 (11)
    EXEC     :ddmonyyyy := '01-Apr-2012';
    
    SELECT        SA.CRAFT
    ,        NVL (SUM (SA.LABORHRS), 0)     as "Loaded Hours"
    FROM             SOL_SCHEDULEBASELINEWOASGMNT        SA
    LEFT JOIN      SOL_SCHEDULEBASELINE              SB   ON   SB.BASELINEID = SA.BASELINEID
    WHERE     SB.DATECODE                       = 'DAILY'
    AND        TO_CHAR (SB.FROMDATE,     'DD-MON-YYYY') = :ddmonyyyy
    AND        TO_CHAR (SB.TODATE,       'DD-MON-YYYY') = :ddmonyyyy
    AND        TO_CHAR (SA.SCHEDULEDATE, 'DD-MON-YYYY') = :ddmonyyyy
    GROUP BY  sa.craft
    ORDER BY  sa.craft     ASC
    ;
    

    It's very similar to your original query, where you have used TO_CHAR on all your DATE columns.

    Moreover, it would be more effective liaison conve\rt variable of a DATE, rather than convert the DATE on each row of a VARCHAR2. In other words, replace the comparisons as

    AND        TO_CHAR (SA.SCHEDULEDATE, 'DD-MON-YYYY') = :ddmonyyyy
    

    with

    AND        SA.SCHEDULEDATE >= TO_DATE (:ddmonyyyy, 'DD-MON-YYYY')
    AND        SA.SCHEDULEDATE <  TO_DATE (:ddmonyyyy, 'DD-MON-YYYY') + 1
    

    If is a coding more. It is up to you to decide if the efficiency improvement is worth.

    Published by: Frank Kulash, April 1, 2012 20:31

  • Query regarding CPU patches

    Hello

    According to my understanding CPU patches are released every quarter for each version & the realease of oracle database.

    I use Oracle 10.2.0.3 on IBM - AIX 5.3 (64-bit).

    I checked the link to metalink below.

    Patches and updates-> Oracle Server/tools-> last Patchsets-> latest version of the Oracle/tools Patchsets-> server then selected oracle database and OS version-> Patch Type selected as all-> ranking selected under high security-> Go

    But the above gives me a list of CPU patches!

    So it is not mandatory that each and every six months we will have a new patch oracle CPU? Or I make a mistake in the selection above?


    Thanks in advance.


    Best regards
    oratest

    Hello

    Patches of CPU Oracle releases for currently taken versions support only.

    And the latest patch of CPU to 10.2.0.3 was Jan 2009 CPU-7592354

    I hope this helps...

  • Query regarding oracle functions

    Hi all

    I tried to work with decode them and output of NVL to get the following:

    Output value
    1 NULL
    0 1
    1 1
    2 2
    3 3


    to do this, I wrote the following query:
    SELECT DECODE (NVL(high_value,1), 0.1, NVL(high_value,1)) in tab1.

    Can there be a replacement of this using other functions?

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Solaris: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    Thank you
    Nikhil

    Can be with decoding

    with t_data as
    (
    select null as val from dual union all
    select 0 from dual union all
    select 1 from dual union all
    select 2 from dual union all
    select 3 from dual
    )
    SELECT
         val,decode(val,null,1,0,1, val) output
    from t_data
    
  • Query regarding namespaces

    Hello
    I am quite new to XML format. Last day, I read on namespaces. I read that they are used to resolve name conflicts. Is there another reason to use? Another question that came in my mind was this: suppose that I write the following text: -.


    <? XML version = "1.0"? >
    < root xmlns:ns1 = "http://www.abc.com.
    xmlns:ns2 = "http://www.abc.com" >

    < ns1:name > CBA < / ns1:name >
    < ns2:name > XYZ < / ns2:name >

    < / root >


    In the example XML document above, ns1 and ns2 refer to the same URL. Then there will be an error, or it will mean that the two name tags reside in the same namespace? Could you help me with some links where I can study the namespaces?
    Thanks in advance

    Published by: user11930797 on July 24, 2010 04:48

    Hello

    with
    xample
    as
    (select xmltype('
    ABC
    XYZ
    ') x
    from dual)
    select extract(x, '/root/ns1:name', 'xmlns:ns1="http://www.abc.com"')
    from xample
    

    As a result:

    ABC
    XYZ
    

    So yes, both of these are in the same namespace.

    There are definitive sources on namespaces
    XML 1.0 http://www.w3.org/TR/REC-xml-names/
    XML 1.1 http://www.w3.org/TR/xml-names11/

    HTH,

    Chris

  • Query regarding recovery of selected records from table

    Hi all

    I have a table as below:

    NUM1 NUM2 TYPE

    1 2
    1 2 S
    2 3 S
    3 4
    3 4 S
    4 5S


    If for a record TYPE = 'A' then do not select the records for these num1 and num2.

    For example: for 1 = num1 and num2 = 2 there are two records with type = 'A' and ', recorded only with the type 'A' should be selected.

    Output should be like this:

    NUM1 NUM2 TYPE

    1 2
    2 3 S
    3 4
    4 5S

    Please could someone help me in this query.

    Any help would be much appreciated.

    Thanks and greetings
    Anuj

    Just the MIN function will get what you want

    SQL> with t
      2  as
      3  (
      4     select 1 num1, 2 num2, 'A' type from dual union all
      5     select 1, 2, 'S' from dual union all
      6     select 2, 3, 'S' from dual union all
      7     select 3, 4, 'A' from dual union all
      8     select 3, 4, 'S' from dual union all
      9     select 4, 5, 'S' from dual
     10  )
     11  select num1, num2, min(type) type
     12    from t
     13  group by num1,num2
     14  order by num1,num2
     15  /
    
          NUM1       NUM2 T
    ---------- ---------- -
             1          2 A
             2          3 S
             3          4 A
             4          5 S
    
  • Query regarding SQL logs

    I'm currently working on database forensics, if I do some manual changes in the database through some sql queries there no entry in the logs to prove...

    Can anyone suggest me some tools that can give the desired result. (i.e. pulled the log of all manual queries)

    PS I am using SQL Server 2005

    Any help would be appreciated

    Thank you.

    Hello

    Your question is beyond the scope of this community.

    Please repost your question in the SQL Server TechNet Forums.

    https://social.technet.Microsoft.com/forums/SQLServer/en-us/home?category=SQLServer

    See you soon.

  • Query regarding different refreshing data from the grid when returned from a workflow

    Hi Experts,

    JDEV version is: 11.1.1.5

    Our application uses dynamic tabs the user interface shell.

    Whenever the user connects, it is taken in A TAB.

    Since the TAB A, the user navigates to TAB B.

    TAB B has a GRID B(table with a few records).

    Column A on TAB B has a hyperlink which, once clicked on will open a stream of different tasks in a different tab.

    Click on the column of hyperlink for the different lines will open different tf (under certain conditions).

    By clicking on the hyperlink, that the method _launchActivity(String title, String taskflowId, boolean newTab) is used, which the TF open in a new tab.

    The user works on the TF (in a new tab) which opened on click of a hyperlink in the column is and click on SAVE.

    Click to save some operation and removeCurrentTab method is called which will close the current tab, and control passes to the first tab (TAB A).

    The problem:

    Once the user tries to click or to return to the TAB B the WHAT GRID B is never updated that we cannot get the descriptor to refresh the data in the grid.

    Any suggestions would be much appreciated.

    Thank you

    Jean Claude

    huh, I thought it was another library in question.

    In all cases, you can use contextual event (when you close the current tab).

    The second option is to navigate to the method executeQuery by code call activities:

    https://blogs.Oracle.com/jdevotnharvest/entry/how-to_navigate_in_bounded_task_flows

  • Query regarding VCA and clustered environment

    Hi all, we are currently a slight dilemma and need some advice/help with the installation of clustered environments in VC 4.1.

    Here's our installation composed of 2-pole in a data center:

    Cluster_01

    VCA Mode on Intel 45nm Core 2 Xeon

    2 x servers Dell PowerEdge M600 blade installed with ESX 3.5 (failure of waiting to rebuild with esxi 4.1)

    4 Dell PowerEdge M600 blade servers with ESXi 4.1 x
    E5450 CPU Chipset
    Enough clustered resources to satisfy a host failure.

    Cluster_02

    People with disabilities VCA

    2 x Blade Server PowerEdge of Dell M610 installed with ESX 4.0 (failure of waiting to rebuild with esxi 4.1)
    E5540 CPU Chipset
    Resources on the host for the loss of a node in the cluster.

    * We combine the hosts in a single cluster and enjoy the VCA mode the question?
    * It would be any degradation of performance of guests running?
    * If the newest blades are added to this group in the future what exam must we do? Once again, if CPU

    features are hidden to make it compatible with the cluster that would frustrate the purpose of again model

    Blade and features of the CPU?
    * If we consolidate the clusters we simply turn off guests, remove hosts in the cluster and add the cluster 1 then restarts?

    * Don't disable us the VCA mode in Group 1 and keep configuration cluster 2?

    Your help is greatly appreciated.

    Because the virtual machine are running on a recent processor without activating EVC, you can't allow him to 'downgrade' function CPU.

    You must stop the virtual machine, put the host in maintenance mode and migration in the EVC cluster.

    André

  • Query regarding the change of the background color of an input text

    Hello
    I want to change the background color of an input text element. When I tried with the background color inline style, he has changed the color of the label instead of changing the background color. Is there a way I could do?
    Thanks in advance

    Hello

    Use the contentStyle property (or counting af: inputText::content if you want to change it in one place for all input text fields)

    Frank

  • Query regarding changing the type of human task

    Hello
    I'm new to BPM. I created a process to two tasks and selected by mistake the two human tasks with the motif of the initiator. And now I get this compilation error that says my process contains several tasks of initiator. Is there a way I can change the type of simple human task after the process has been created?
    Thanks in advance

    afraid to say it, but you must create a human task once more... Sorry, but once created, HT is not editable through front end Oracle BPM

  • A query regarding Cairngorm events

    I'm new to cairngorm.
    I'm designing a StudentApplication using Flex with Cairngorm.
    I am struck at writing a Cairngorm event class. Please guide me

    Assume that this StudentApplication is suppourting Create, Delete, Update, read operations.

    My question is what I have to write 4 event classes, every representative of this operation.

    Or is it possible to do so in an event class by taking 4 different constant Sring, each representing the appropriate Action.

    package com.control
    {
    import com.adobe.cairngorm.control.CairngormEvent;

    public class CreateEvent extends CairngormEvent
    {


    }
    public static const EVENT_CREATE_STUDENT: String = "EVENT_CREATE_STUDENT";
    }

    My question is what I need to do Create, Update, Delete, reading for all events
    Event of my Application?

    Please guide me.

    Thanks in advance.

    Hi Kiran,

    You can write all the events in a class single say StudentEvent class and perform the appropriate action according to the type of event (delete, update, add... etc) but if you do you need to process the result returned by the remote service based on the type of event in command later and write your logic.

    for ex:

    In your layer (StudentCommand) command in the results... Manager function you need to treat them that way...

    public function result (data: Object): void

    {

    If (data! = null)

    {

    If (_eventtype is "deletestudent")

    {

    Write you the logic to remove the student

    }

    ElseIf (_eventtype == "createstudent")

    {

    Write logic to create the student

    }

    ElseIf (_eventtype == "updatestudent")

    {

    Write logic to update students

    }

    on the other

    {

    Write you logic to read the details of the student

    }

    }

    }

    deletestudent, createstudent, updatestudent and readsrstudent are the event four guys who you here as of constant static in StudentEventclass.

    If you want to write event 4 classes for all then also its good so that you can have the class wrapper for all events.

    If you want to have custom and reduces the code, then use the single event class. Its based on your requirement...

    Thank you

    Jean Claude Chari

Maybe you are looking for