Tricky SQL - is possible using just SQL and not of PL/SQL

Hi all

Here's my data

create table experience (exp_id number (10), exp_name varchar2 (20), root_exp_id number (10));
insert into a values (642, 'Test', 5172) experience;

create table experience_node (exp_node_id number (10), exp_node_type_id number (2));
insert into experience_node values (5172, 1);
insert into experience_node values (5173, 2);
insert into experience_node values (5174, 2);

create table experience_connector (exp_conn_id number (10), exp_conn_type_id number (2), exp_node_id number (10), parent_exp_node number (10));
insert into experience_connector values (1, 5173, 4287 5172);
insert into experience_connector values (4288, 2, 5174, 5173);
insert into experience_connector values (2, 5175, 4289 5174);

When you run these queries:

Select parent_experience_node_id
of experience_connector
where experience_node_id = 5175;

Select parent_experience_node_id
of experience_connector
where experience_node_id = 5174;

Select parent_experience_node_id
of experience_connector
where experience_node_id = 5173;

Select parent_experience_node_id
of experience_connector
where experience_node_id = 5172;

gives 5174, 5173 and 5172 and null. exp_node_type_id = 1 and exp_node_conn_type_id = 1 indicates that it is at the root. Hope my explanation is useful. Is what I'm trying to get - to get the big concession to 5175 grandparent who is 5172. Is it possible to do it with SQL?

Thank you very much for you help.

Best,
Lacombe

user6773 wrote:

We don't know if the level. There could be any number of levels. Is there any other way around? Thank you once again.

Well, you say that you need to root, not great great grandparent? If so, use:

SQL> select  parent_exp_node
  2    from  experience_connector
  3    where connect_by_isleaf = 1
  4    start with exp_node_id = 5175
  5    connect by exp_node_id = prior parent_exp_node
  6  /

PARENT_EXP_NODE
---------------
           5172

SQL> 

SY.

Tags: Database

Similar Questions

  • How to read bfile using dbms_lob.read and not raw characters

    Hi all
    Is it possible to read LOB using DBMS_LOB. READ so that the buffer is displayed in ASCII characters not BELIEVED. Suppose I have the following code:
    --create or replace procedure some_proc is
    declare
    note_clob clob;
    note_bfile bfile;
    note_var raw(10000);
    warning int;
    dest_off int:=1;
    src_off int:=1;
    lang_ctx int:=0;
    amount int:=1500;
    
    begin
    dbms_lob.createtemporary(note_clob,true);
    --note.txt is a text file
    note_bfile:=bfilename('TEMP_DIR','note.txt');
    
    dbms_lob.fileopen(note_bfile);
    dbms_lob.read(note_bfile,amount,1,note_var);
    dbms_lob.fileclose(note_bfile);
    dbms_output.put_line(to_char(note_var));
    
    end;
    /
    The DBMS_OUTPUT. Put_line shows the RAW data instead of its ASCII representation:
    53514C3E2073656C65637420696E7374616E63655F6E616D652C7374617475732C686F73745F6E616D652066726F6D207624
    696E7374616E63653B0D0A0D0A494E5354414E43455F4E414D45092053544154555320202020202020484F53545F4E414D45
    0D0A2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D202D2D2D2D2D2D2D2D2D2D2D2D202D2D2D2D2D2D2D2D2D2D0D0A696E61726109
    09204F50454E0920202020202066697265666C790D0A0D0A53514C3E2073656C656374202A2066726F6D2076247665727369
    6F6E3B0D0A0D0A42414E4E45520D0A2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D
    2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A4F7261
    636C652044617461626173652031316720456E74657270726973652045646974696F6E2052656C656173652031312E322E30
    2E312E30202D2036346269742050726F64756374696F6E0D0A504C2F53514C2052656C656173652031312E322E302E312E30
    202D2050726F64756374696F6E0D0A434F52450931312E322E302E312E300950726F64756374696F6E0D0A544E5320666F72
    204C696E75783A2056657273696F6E2031312E322E302E312E30202D2050726F64756374696F6E0D0A4E4C5352544C205665
    7273696F6E2031312E322E302E312E30202D2050726F64756374696F6E0D0A0D0A5B6F7261636C654066697265666C795D24
    206C736E7263746C207374617475730D0A0D0A4C534E5243544C20666F72204C696E75783A2056657273696F6E2031312E32
    2E302E312E30202D2050726F64756374696F6E206F6E2031332D4A554E2D323031312031363A30373A32330D0A0D0A436F70
    7972696768742028632920313939312C20323030392C204F7261636C652E2020416C6C207269676874732072657365727665
    642E0D0A0D0A436F6E6E656374696E6720746F20284445534352495054494F4E3D28414444524553533D2850524F544F434F
    4C3D49504329284B45593D45585450524F43313532312929290D0A535441545553206F6620746865204C495354454E45520D
    0A2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D0D0A416C696173202020202020202020202020202020202020
    2020204C495354454E45520D0A56657273696F6E20202020202020202020202020202020202020544E534C534E5220666F72
    204C696E75783A2056657273696F6E2031312E322E302E312E30202D2050726F64756374696F6E0D0A537461727420446174
    652020202020202020202020202020202031332D4A554E2D323031312031313A32393A35300D0A557074696D652020202020
    20202020202020202020202020202030206461797320342068722E203337206D696E2E203333207365630D0A547261636520
    4C6576656C2020202020202020202020202020206F66660D0A53656375726974792020202020202020202020202020202020
    204F4E3A204C6F63616C204F532041757468656E7469636174696F6E0D0A534E4D5020202020202020202020202020202020
    2020202020204F46460D0A4C697374656E657220506172616D657465722046696C652020202F7573722F6C6F63616C2F6F72
    61636C652F70726F647563742F31312E322E302F6462686F6D655F312F6E6574776F726B2F61646D696E2F6C697374656E65
    722E6F72610D0A4C697374656E6572204C6F672046696C652020202020202020202F7573722F6C6F63616C2F6F7261636C65
    2F646961672F746E736C736E722F66697265666C792F6C697374656E65722F616C6572742F6C6F672E786D6C0D0A4C697374
    656E696E6720456E64706F696E74732053756D6D6172792E2E2E0D0A2020284445534352495054494F4E3D28414444524553
    533D2850524F544F434F4C3D69706329284B45593D45585450524F43313532312929290D0A2020284445534352495054494F
    4E3D28414444524553533D2850524F544F434F4C3D7463702928484F53543D3132372E302E302E312928504F52543D313532
    Just curious to know if I can do this to DBMS_LOB. READ directly. Another way that I can do is use DBMS_LOB. LOADCLOBFROMFILE and not the DBMS_LOB. READ.

    Kind regards
    Val

    Hello
    Try this

      utl_raw.cast_to_varchar2(note_var)
    

    Edited by: user6806750 the 07.10.2011 01:59

  • Can I set up sync on a computer that is used by others and not share my information?

    I use a computer which I share with others. Any one elses action will appear on my sync account. Can I connect if you use Firefox sync on this computer?

    If other users use your logon in the Windows user account, they will have access to your installation of Firefox and have access to your data in sync.

    It is better for each user to have their own user account to logon or have them share a guest account.

    http://www.Microsoft.com/windowsxp/using/Setup/WinXP/accounts.mspx

  • use of OOP and not

    Hello, I use LabVIEW for a couple of years now and have met a few references to the OBJECT-oriented programming. I read a little of the help file to this topic and some stuff on the forum. I have a basic question that I would like to get an answer before we get too far into it. Basically, why? What gives OOP programmer that he can not do (or is really hard to do) in ordinary LabVIEW? It seems to me that this is another type of cluster. So I must be missing something.

    You are right - in BT, an object is really a cluster.  But there is more to this...

    In the interest of full disclosure - I exactly wrote an app using the OBJECT-oriented programming.  It is an application that uses a set of drivers VISA that I wrote for a USB line spectrometers.  Each type of spectrometer was similar, but necessary functions different hex codes to perform the same functions.  In addition, the format of the data returned by each spectrometer differs.

    I had exactly the same concern that you do before you start.  I decided to use LVOOP for a reason:

    I knew that I would have to expand the drivers in the future.

    I created a parent called spectrometer USB class which had subVIs for all common functions.  I created a child class for each of the types of spectrometers.  In children's classes, no matter where the orders differ between spectrometers, I overroad the Subvi parent class.  In the future when I need to add another type of spectrometer, all I have to do is create another class child and substitute the same subVIs.  99% of my code will not need to change at all...

    In short - OOP offers capabilities, that you have not already.  In my opinion, it's more like a technique of organization that can be used to help manage the code if you have one day to extend.  In my personal experience, it really made me think about the structure of the app and forced me to write highly modular, tight code.

    LVOOP was a bit of a pain to learn (I had to work a bit to understand how to use the dynamic allocation).  But after using once, I expect to use it - I even look forward to it.  However, it is not a cure all... efforts are necessary to implement, so I tend to avoid it for small (and even some middle) scale applications.

    Jason

  • SQL Server 2008 R2 developer: this version include and allow to use ssrs, ssis and ssas intended for a single user?

    This version includes and allow to use ssrs, ssis and ssas intended for a single user

    Hi mikeyjoy,

    For questions about SQL Server, visit the Forums for SQL Server.

    Thanks for posting your question in the Microsoft answers Forum.

  • I use Windows Vista and that you need to download SQL Server 2005 Express Service Pack 4. I get an error code of 64 C. Please tell me what to do?

    I use Windows Vista and that you need to download SQL Server 2005 Express Service Pack 4. I get an error code 64 C help, please.

    Hello

    I suggest you to try the steps below and check if it helps.

    Method 1: Try to reset components to update Windows from the following link, which would help you to install the updates of windows. http://support.Microsoft.com/kb/971058

    Method 2: If the problem persists, then try to set up your computer in a clean boot state, and check to see if the same problem happens.

    By setting your boot system minimum state helps determine if third-party applications or startup items are causing the problem.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or Windows 7:
    http://support.Microsoft.com/kb/929135

    Note: After the boot minimum troubleshooting step, follow step 7 in the link provided to return the computer to a Normal startup mode.

    Method 3: Also try to install the updates manually from the link below.

    http://www.Microsoft.com/download/en/details.aspx?displaylang=en&ID=184

    You can also consult the following link for more information:

    Troubleshoot problems with installing updates.

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-installing-updates

    Hope this information is useful.

  • I have creative cloud for just PS and LR which allows me to have this on 2 computers. I now need on a machine 3, is - it possible?

    I have creative cloud for just PS and LR which allows me to have this on 2 computers. I now need on a machine 3, is - it possible?

    Yes, you can install an unlimited number of computers.

    You cannot connect (and therefore to start cc programs) on more than 2 computers at the same time.  But adobe makes it easy to disconnect other computers from a 3rd computer even though it is not really a restriction.

    just install the application of cc on your computers desktop, https://creative.adobe.com/products/creative-cloud and use it to install your lr and ps.

  • Hi, I want to know if it is possible to install the version pro on several computers, or just one and if we want to add later that cost more?

    Hi, I want to know if it is possible to install the version pro on several computers, or just one and if we want to add later that cost more?

    A single user license allows installation enabled on both machines.  These two machines you can only use the software on one machine at a time.  You will need the licenses as the number of machines that you want to use the software on at the same time.

  • bought photoshop elements 11 year last for windows and use it in my office. The office is now crashed and not usable. So I bought iMac now. Is it possible to make the trade more to change the license in version iMac for a small fee. If not, can I partitio

    bought photoshop elements 11 year last for windows and use it in my office. The office is now crashed and not usable. So I bought iMac now. Is it possible to make the trade more to change the license in version iMac for a small fee. Otherwise, I can partition the hard drive in the iMac and install windows and also photoshop elements? What is the best alternative? Why?

    A license of Photoshop Elements is good for Mac and Windows, it should be just a matter of download the Mac version and using your serial number to activate it.

    PES 10: 11 - http://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-10-11-downloads.html

    If you have any problem with the activation contact Adobe support using cat... Start here  If after selecting the relevant answers, you are unable to find a solution, choose "still need help? Contact us. "and the contact Chat option.

  • How to monitor the SQL perticuler using the INDEX or not?

    I'm running on a long-term quary and the output is coming very late. So, I want to know that the quary sql uses the index or not? How do I know that?

    Hello

    You have not provided your db version?
    You can check v $ object_usage in a simple way. Try to check the explanation of your query if you current sql is by using your existing index or not.
    Check with dbms_xplan.display

    Request to go through the links of Ask tom and jonathan lewis
    http://jonathanlewis.WordPress.com/2007/02/15/index-not-used-10G/
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:736825544526

    HTH

    -Pounet N

  • Photos can work using just an external HARD disk and leave my only intern?

    Hello

    I am using v1.5 Photos. On my Macbook HARD internal disk fills up very quickly. Fortunately, I have a nice external 1 TB drive and I would like to:

    (1) move all my photos on the external drive and direct Photos program so search the folder on the external HARD drive to find all photos.

    (2) when I import pictures from my camera in the future, that the Mac them automatically in the folder of photos on the external HARD disk and not keep fill the space limited on my Mac small disk internal.

    Is this possible? I remember that I was able to do it with iTunes years when I used a Powermac with 4 x internal HDD of various sizes. iTunes has been able to see the music on each disk files and present them to me as a single list of iTunes.

    I'm not interested in using iCloud at all, I have everything on HARD drive and memory sticks and I am satisfied that, as it provides all the storage I need and I only use a computer for my work.

    Thanks a lot for your help.

    Yes, it is possible to keep the pictures library on an external drive. Make sure that the unit is running at the launch of photos from your Mac.

    See this discussion for detailed instructions of another user.

    How can I move Photos on external hard drive?

  • I just bought an Iphone 6s and not yet am possession of en from the Sim Card. Ook, do you know if I can use the phone including applications via Wifi and put the chip later? Thank you. Renault JL

    I just bought an Iphone 6s and not yet am possession of en from the Sim Card. Ook, do you know if I can use the phone including applications via Wifi and put the chip later? Thank you. Renault JL

    No, because if you bought a new iPhone, then you need a SIM card to activate it before you can use the wifi applications.

    This is a phone after all, you don't need a sim card any to be able to activate it.

  • Why can't just open and use files Z5 for a text called 'The Theatre' adventure game?

    I'M in TRAIN OF DOWNLOAD AND USE FILES/PROGRAMS to PLAY TEXT ADVENTURES ESPECIALLY ON CALLED 'THE THEATRE' [A TEXT ADVENTURE USING A z5 FILE HAD each time I HAVE TRIED TO OPEN AND RUN IT I KEEP GETTING THE MESSAGE WINDOWS don't IS NOT RECOGNIZE this TYPE of FILE. ANY HELP PLEASE.

    To simplify things, download and install the Windows version of
    http://www.ifarchive.org/if-Archive/Infocom/Interpreters/Frotz/WindowsFrotzInstaller.exe

    I just tried and, once installed with all the default options, you can double-click a .z5 file to launch the game and interpreter.

  • How to get a handle to the window to screen using just group id and the id of the window?

    Hello

    We are trying to develop a video application, and we use ForeignWindowControl to display the video on the screen.

    We have those ForeignWindowControl declared and defined in a QML file that appears as needed.

    Using the CameraAPI, we are able to get local video displayed correctly on the local video ForiegnWindowControl. For this we have just the window group id and the id of the window api camera and it automatically configures the window newly created by the camera to the position API and the size defined in the QML file.

    However, this is isn't the case with the video remotely. Since there is no method/function similar to the createViewFinder of the camera api, we need to create a new window of ourselves that goes under the Group shared by the ForeignWindowControl remotely, using screen_create_window_type and set all the required parameters.

    To view the video, hard-code manually the position and size of the newly created window so that it corresponds to the position and the size of ForeignWindowControl remote in QML file and is displayed correctly.

    My question is how to find the ForeignWindowControl using just the group id and the id of the window? the way in which the cameraAPi done in-house?

    Any help would be appreciated.

    Thank you.

    There are 3 ways to associate a window with a ForeignWindowControl.

    1 tell the ForeignWindowControl to expect a window with a given windowId.  Then after that libscreen allows you to create your window with the same windowId, use screen_join_window_group() to adhere to the same group that uses the FWC.  The FWC should automatically capture this event and associate the window itself.  This is how the camera it.

    2. call the bindToWindow() of the ForeignWindowControl method to associate the FWC a particular windowId/groupId.  Similar to the #1, but doesn't seem more useful if you create the FWC after the window of the screen has been created.

    3. call the setWindowHandle() of the ForeignWindowControl method.  Similar to the #2, but instead of using windowId/groupId, you spend just the actual handle.

    See the FWC docs:

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__foreignwindowcontrol.html

    If you have created the window, you can use one of the 3 approaches.  If the window has been created in a different process (eg. mm-engine rendering, or photo-service device), then generally #1 is the approach you would use.

    See you soon,.

    Sean

  • Is it possible to watch video remotely using an ipad and the Camcorder HDR-CX330 wireless?

    Is it possible to watch video remotely using an ipad and the Camcorder HDR-CX330 wireless? I could see the pictures, but really want to see videos?  I use the PlayMemories application for remote control. Any suggestions?

    Hi bill54107,

    Welcome to the community of Sony!

    Unfortunately, you can not view videos recorded wireless using your mobile device. You can transfer videos on your iPad, but only if they are saved in the format. Mp4 format AVCHD files can be transferred wireless to a tablet or a smartphone. Enable the video double setting Rec to shoot AVCHD and Mp4 format at the same time.

    You can only use the transfer of photos and AVCHD videos wireless when you download Wireless Auto Import (for Mac) and the House of PlayMemories.

    If my post answered your question, please mark it as "accept as a Solution. Thanks_Mitch

Maybe you are looking for