Getting the parenet id along with the child ids in hierarchy query results

create table test_test2 (do_id_tp varchar2(32),do_id number ,do_up_tp varchar2(32),do_up_id number)
insert into test_test2 values('A_S',100170,'A_S',100001);
insert into test_test2 values('A_S',1001054,'A_S',100001);
insert into test_test2 values('A_S',1001055,'A_S',100001);
insert into test_test2 values('A_S',1001053,'A_S',100001);
insert into test_test2 values('A_S',1001056,'A_S',100001);
insert into test_test2 values('A_S',1001051,'A_S',100001);
insert into test_test2 values('A_S',1001052,'A_S',100001);
insert into test_test2 values('A_S',100358,'A_S',100170);
insert into test_test2 values('A_S',100359,'A_S',100170);
insert into test_test2 values('A_S',100441,'A_S',100170);
insert into test_test2 values('A_S',1001047,'A_S',100441);
9/code]
Upon executing the following query , i'm getting the childs of 100001 and the childs of childs of 100001 etc..
That if fine .But in the output i'm not getting the parent id i.e; 100001 (which is in the where condition)
How to get the parenet id along with the childs id.( without writing the UNION select 100001 from dual)SELECT do_id
FROM (
SELECT d.do_id, d.do_up_id
FROM test_test2 d
WHERE d.do_up_tp = 'A_S' ) m
CONNECT BY NOCYCLE PRIOR m.do_id = m.do_up_id
START WITH m.do_up_id =100001
Edited by: smile on Jan 12, 2012 6:50 PM

If you wish the root parent as a column in your select, you can use CONNECT_BY_ROOT:
SELECT
connect_by_root(do_up_id) root,
do_up_id parent,
do_id
FROM (
   SELECT  d.do_id, d.do_up_id
   FROM test_test2 d
   WHERE    d.do_up_tp = 'A_S'
) m
CONNECT BY NOCYCLE PRIOR m.do_id = m.do_up_id
START WITH m.do_up_id =100001;But if you really wish an extra row in your output with 100001, then your problem is that you do not have a record in your data with do_id = 100001.
Then you either need such a record in your data, or you need to create such a row with for example union all - something like this:
SELECT
do_id
FROM (
   SELECT  d.do_id, d.do_up_id
   FROM test_test2 d
   WHERE    d.do_up_tp = 'A_S'
   UNION ALL
   SELECT 100001 do_id, NULL do_up_id
   FROM DUAL
) m
CONNECT BY NOCYCLE PRIOR m.do_id = m.do_up_id
START WITH m.do_up_id IS NULL;

Similar Messages

  • How to make plant default on the line item along with the item category

    Hi All,
    I want to default Plant on the line item along with the item category.In order to meet the following scnario.
    1. I have two plants,first plant is maintained for the valuated item and the second plant is maintained for the non valuated item (Free Goods).
    Whenever user is entering an item in the sales order for which corresponding free goods item is maintained in the master record.System is proposing two lines items in the sales order.
    First line item is the main item which appears along with the Plant 1 which contains valuated items
    Second line item is for the Free of charge item which is being proposed from Plant 2, which contains the non valuated items.
    I want that the system should always propose Plant 1 with main item and Plant 2 with the Free of Charge item by default. (Along with the item category TAN and TANN)
    Rahul

    Delivering Plant is determined in the following order
    1. Customer material info record.
    2. Customer master
    3. Material master.
    Use one of them an default your plant.
    I think in your case you can use the materila master which will give an item level plant different. The other two will default the plant at the header level.
    regards
    jude

  • How do you copy and paste track changes material in Pages from one point in a document to another and keep both the old text along with the track changed thus far in the new pasted location?

    Depending on whether track changes is on/paused, Pages thinks the pasted material is either all new and thus highlights it as a big track change or just copies the old material along with the edits as plain text so that I cannot see my track changes. I need to be able to copy and paste in the same document and still be able to see the older text along with the changes to certain sections thus far. Is this possible? I need a step-by-step "talk to me like I'm five" instructional if what I would like can be done.
    Thanks for any help!
    Message was edited by: C.M.W.

    What version of Pages?
    What OS, iOS or OSX?
    Are you sure you have the Table selected and not a cell or just contents?
    Peter

  • My MAcBook will not boot up. I get A white screen along with the light on the front of the mac with a beeping.

    My MacBook will not boot up all I get is a white screen with the light on the front of the mac blinking and a beeping.

    Check this Apple support article https://support.apple.com/kb/HT1547

  • HT4528 I just bought an IPhone 4s and when I plug it into my Windows 7 Toshiba it does not recoginze the phone...I have already removed the ITunes software along with the rest of the software and reinstalled...no go.I want to transfer phone video to my co

    I just bought an IPhone 4s and plugged it into my Toshiba Windows 7 (64 bit) OS and it failed to recognize the phone.  I checked in the tech community and discovered that I need to remove all the software assoicated with the phone and start over....I followed the sequence exactly...reinstalled the software and it still doesn't work.  I am trying to download the IPhone 4s video to my computer and without a USB interface that works my memory capactiy will fill up fast....I've already been into the control panel....stopped and restarted the Apple service....I am stuck...can anyone offer some suggestions or knwo if there is a fix for this issue..??
    Thanks,
    Eric

    I solved my own problem....I simply moved the cable to another port while moving the mouse to the USB ports on the opposite side of the computer....and the computr finally recognized the phone...I know it sounds weird but it worked...so if you are having the same problem that  had trying removing all the crap you have plugged into the USB ports on your computer THEN plug in your IPhone 4s...use the cable that came with the phone and nothing else...good luck..>!!!

  • I brought in a slideshow but photos didn't include comments.  How can I get my comments imported along with the pictures?

    I brought in a slideshow but photos didn't include comments.  How do I get my comments?

    First make sure you've added the comments you want to show in the Add a Description field in iPhoto or in the Title field.  If you put them in the Title field and you envoke the feature in iDVD you won't have to delete the title from each slide to give you just the desciption.  Or batch remove the Titles from all the photos before you add them to the iDVD project. You can allways get them back with the Photos ➙ Batfch Change menu option later on.
    Click on the cog wheel menu button at the bottom and select Show titles and comments checkbox.
    Happy Holidays

  • How can I print the Album name along with the Contact Sheet created from the photos it contains?

    I have my photos organized into albums.  I would like to print a contact sheet for each album, but would like it to include the album name.  This seems like a very basic part of organizing, but it's not overly apparent how to do it.  I would also like to resize the caption font on the contact sheet, too.  Any suggestions?

    Thanks for your replies.
    When you say "book creation," are you referring to the Photo Book option?  Unless I can create a custom template, that seems somewhat limiting, as there are only a few templates to select from.
    I'm trying to come up with a method to manage headshots of staff, the printout of which would be distributed to hotel and security personnel while our group travels (the included Photo Book templates are not appropriate for a straight-up, columnar layout like this requires). My thought was to keep each department's headshots in its respective Album, which could then be quickly printed and distributed.  Staff for each department rotates in and out on a regular basis, and the Elements Organizer seemed like a good way to quickly add, caption and place into each Album the appropriate pictures.  Contact Sheet printing seemed to be a quick way to accomplish this, but I was hoping to get the Album name (i.e. department name) at the top of the printout.
    I printed the contact sheet to a PDF (I have Acrobat Pro XI), then inserted it into a Word doc, as you suggested.  While it does allow for headers, etc. it does add a couple of additional steps to the process, but more importantly, I'm finding that the image captions in the PDF are blurred, and not crisp enough to read easily (it may be better if I had font control in the PE Contact Sheet).
    So maybe I need more of a desktop publishing app (more than I was wanting to spend), but the Organizer gives me a good process for quickly managing my photos.
    Any other suggestions or comments would be greatly appreciated.

  • HT201335 Will the audio mirrors along with the video ?

    I was searching all over to figure out more on screen mirroring feature via Apple TV . Everywhere it talks about screen mirroring , does it mean that only video what is appearing on the iPhone 4s screen is mirrored ? How do I get the audio to the HD TV ?

    iPhone 4S mirroring sends both video and audio to the TV provided airplay of the content is supported.
    With non-mirroring Airplay certain things only send teh audio as teh content owners block video airplay, but I've never heard of anyone getting video not audio, only the reverse.
    AC

  • I'm not sure I have iCloud on, and my iPad is showing the usb cord, along with the iTunes logo, only able to shut off. Turned it back on, same logo and usb cord. Help?

    I was trying to get the new iOS update, and the iPad froze. I've seen others who have the same problem, but they had the iCloud and things like that. I have a few stories on there, and I'm not about ready to lose them, as I was stupid enough to not transfer them to my computer or anywhere else.
    I went onto iTunes, hoping it would do that "restore iPad" thing, but so far, nope. I think it'd be fair to also inform that my iPad has been that was for three days, and I'm at a loss at what else to do. Can someone please, please help? Lord knows I need it...

    recovery mode
    open itunes on computer
    plug cable into computer not phone
    turn phone off
    hold home button and plug cable into phone.  do not release home button until an itunes graphic appears on device.
    look to computer shold have message about recovery mode click ok and restore
    Peace, Clyde
    if u need an article see
    http://support.apple.com/kb/HT1808

  • Why do I get a new tab along with the website I am opening?

    Every time I am opening a website, I am getting a New Tab attached to it. This tab can not even be closed.

    Hi,
    Please check if this happens in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode]
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [http://support.mozilla.com/en-US/kb/Uninstalling+add-ons Uninstalling Add-ons]
    [http://kb.mozillazine.org/Uninstalling_toolbars Uninstalling Toolbars]

  • HT1692 Can I clear my contacts off y iphone, and then sync with iTunes and return them back to y iphone, my IPHONE keeps retaining nos that it shouldn't, I delete them off, during edit, and they just return and added to the new contact along with the new

    I Really would like some help, this problem has been with me for a couple of months,
    i seem to be having problems with my contacts.
    WHen I edit a contact, and pop in a new contact number, and delete the old number. It looks like it has been done.  when I go to write a message or go back into the contact, it has the old number there again, I have deleted off the computer contacts as everything is under I cloud anyway. It seems fine on my iMac, but still retains the old nos, and other info, mainly on my IPHONE.  Would it be useful to take all contacts off my phone, and reinstall them from my iTunes, or back up of whatever..  I am a nana, so please. Be gentle with me..
    Regards
    Jan .

    Janandbruce wrote:
    I have deleted off the computer contacts as everything is under I cloud anyway.
    On the iPhone, Settings > iCloud, contacts Off then back on.

  • There is a choice of various languages in the keyboard. Is there any way to add further symbols or emoticons to the existing keyboard along with the language being used?

    How to add symbols like emoticons and others to the keyboard in operation

    206157 wrote:
    How to add symbols like emoticons and others to the keyboard in operation
    For things not in the Emoji keyboard, you can use an app like Cymbola, Unicode Map, etc.

  • Using NonCatalogLogger along with the LogMBean

    Hi anybody
    According to the API, the NonCatalogLogger class provides application services
    for logging error messages to the weblogic server log. The name, location and
    other properties of the logfile are determined by the LogMBean for the server.
    Now, I have the instance of the LogMBean running in the server and using this
    instance I am able to configure our weblogic server's logging configuration from
    any client machine. But I am not able to log any message from a client machine
    into the server's log file. That is I am not able to use the LogMBean object along
    with the NonCatalogLogging object.
    Do you have a suggestion?
    Regards
    Zakaria Chowdhury

    http://edocs.bea.com/wls/docs60/javadocs/weblogic/management/configuration/L
    ogMBean.html
    "Rajan Annadurai" <[email protected]> wrote in message
    news:3ced8eb9$[email protected]..
    >
    hi Sanjeev,
    "in addition to FileName you can specify any LogMBean prop for a client inthe same
    manner"
    Can you please list down the LogMbean property to set rotation size. I amnot able
    to find it any where in the documentation.
    thank you,
    Rajan
    "Sanjeev Chopra" <[email protected]> wrote:
    Clients cannot log to the servers logfile. If you use NonCatalogLogger on
    the client, it creates its own file. By default however, the file is
    turned
    off. You need to turn it on by specifying the FileName prop of theLogMBean
    for that client.
    Since client config is not done thru MBeans, the way you define this is
    with
    system props i.e. -Dweblogic.log.FileName=....
    (in addition to FileName you can specify any LogMBean prop for a client
    in
    the same manner)
    "Zakaria Chowdhury" <[email protected]> wrote in message
    news:[email protected]..
    Hi anybody
    According to the API, the NonCatalogLogger class provides applicationservices
    for logging error messages to the weblogic server log. The name,
    location
    and
    other properties of the logfile are determined by the LogMBean for theserver.
    Now, I have the instance of the LogMBean running in the server and
    using
    this
    instance I am able to configure our weblogic server's loggingconfiguration from
    any client machine. But I am not able to log any message from a clientmachine
    into the server's log file. That is I am not able to use the LogMBeanobject along
    with the NonCatalogLogging object.
    Do you have a suggestion?
    Regards
    Zakaria Chowdhury

  • To capture the selected rows along with edited field contents in alv report

    Dear All,
             I do have requirement where, in alv report output one field is editable and need to save the content of the edited field along with the selected rows.
             For example If there are 10 records displayed in the alv output with 20 fields.
    Out of this 20 fields one field (say XYZ) is editable. Also i have already created a new pushbutton (say ABC) on alv output. Now in the alv output if we maintain some value in the field (XYZ ) for the 2nd and 4th record and select this two records, and when clicked on the pushbutton (ABC) it has to update the DB table.
          I am using the Func Module  'REUSE_ALV_GRID_DISPLAY'. 
          Your early reply with sample code would be appreciated.
    Thanks in Advance.

    HI Naveen ,
    There is an import parameter "i_callback_program" in the function module,
    plz pass the program name to it.
    Capture the command by passing a field of type sy-ucomm to "I_CALLBACK_USER_COMMAND ".  Check the returned command and
    and program a functionality as desired.
    u can try the event double_click or at line selection. there u can use READLINE command to c if the line has been selected.
    In case it is , process the code segment.
    Regards
    Pankaj

  • Display more than one Graph in the same page along with report datails

    Hi,
    I have  to display 3 lines out put along with the 3 GRAPH’s  below corresponding to the 3 lines  in the same page of a the report output. .How do i achieve this?  The function modules like ‘GRAPG_2D’,   ‘GRAPG_3D’ brings the graph in separate pop up, but I want all the 3 graphs in the same page along with the some text above those graphs (ie my report details in 3 lines).
    Could you please let me know how to achieve this?
    Waiting fro your kind suggestions,
    Regards,
    Steve

    Hi,
    Refer to the following code to display graphs in report.
    DATA: BEGIN OF ITAB_DATA OCCURS 0,
    DATANAME(15),
    QUANTITY1 TYPE I,
    QUANTITY2 TYPE I,
    QUANTITY3 TYPE I,
    END OF ITAB_DATA,
    BEGIN OF ITAB_OPTIONS OCCURS 0,
    OPTION(20),
    END OF ITAB_OPTIONS.
    ITAB_DATA-DATANAME = 'Electricity'.
    ITAB_DATA-QUANTITY1 = 55.
    ITAB_DATA-QUANTITY2 = 62.
    ITAB_DATA-QUANTITY3 = 59.
    APPEND ITAB_DATA.
    ITAB_DATA-DATANAME = 'Gas'.
    ITAB_DATA-QUANTITY1 = 35.
    ITAB_DATA-QUANTITY2 = 52.
    ITAB_DATA-QUANTITY3 = 44.
    APPEND ITAB_DATA.
    ITAB_DATA-DATANAME = 'Water'.
    ITAB_DATA-QUANTITY1 = 18.
    ITAB_DATA-QUANTITY2 = 22.
    ITAB_DATA-QUANTITY3 = 19.
    APPEND ITAB_DATA.
    CALL FUNCTION 'GRAPH_MATRIX_3D'
    EXPORTING
    COL1 = 'Jan'
    COL2 = 'Feb'
    COL3 = 'Mar'
    TITL = 'Utility Expenses in US$.'
    TABLES
    DATA = ITAB_DATA
    OPTS = ITAB_OPTIONS
    EXCEPTIONS
    OTHERS = 1.
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

Maybe you are looking for

  • Passing report results parameters to different page

    Hi y'all, I was wondering how report results (results acquired by custom written sql query) can be passed to different pages? Can anyone help or provide me with a link which can point me to some documentation on this subject. Thanks, Cleo

  • How to confiure sendmail in sloaris 10

    pls explain me how to setup sendmail .in my concern we 30 windows work station one solaris 10 x86 server i want to configure sendmail

  • Multiple monitor -- where application displayed after loading?

    I have a question. After installing Mavericks I have one very annoying problem with multiple displays. When I open an application (e.g. Outlook), I prefer it opens in the second monitor. Before that, if you drag it to the second monitor it remembers

  • VC and BI Integration Wizard

    How to use BI Integration Wizard in vc 7.1 ? because i can not fund "BI Integration Wizard" on menu in vc 7.1 , I use CE development SR5 version .

  • 10.8.3  - Messages still out of order after waking from sleep or restart

    This bug is still present in Messages, although it was supposed to be fixed with 10.8.3. I've tried both the App store update to 10.8.3 as well as the combo updater. When I check Messages' version after each, it's 7.0.1 (3318), and the copyright date