Short cut problem? Can it be implemented by using PL/SQL?

I am an oracle fan from China. This is the first message I published on the forum. Thanks your kindness.
Now, We are faced with a problem of the shortest roadsect problem. The table has such columns:
startcrossingid, endcrossingid, roadsectid, roadsectlength
1 2 1 100
1 3 2 90
1 4 3 80
2 5 4 70
3 5 5 85
4 5 6 95
Column startcrossingid means the start point of a roadsect. column endcrossingid means the end point of a roadsect. column roadsectid means a roadsect.
column roadsectlength means the length of a roadsect.
We want to implement it by using PL/SQL, such as by
a stored procedure. I am trying to find the solution.
If you have some usful suggestion or code, please give
me some help. Any suggestion is very thankful!
Xiexie!

Hi,
Good challenge, try it for sortest way from 1 to 5 :
SQL> select * from road;
STARTCROSSINGID ENDCROSSINGID ROADSECTID ROADSECTLENGTH
              1             2          1            100
              1             3          2             90
              1             4          3             80
              2             5          4             70
              3             5          5             85
              4             5          6             95
              5             6          7              5
7 rows selected.
SQL> select x.roadsectid
  2  from ------------------------------------
  3  (select *
  4  from
  5  (select abs(num1-num2) as path,b.*
  6  from (select level as num1,rownum as num2,a.*
  7        from road a
  8        where ENDCROSSINGID<=5
  9        and    STARTCROSSINGID>=1
10        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) c) x,---------------------------------
11  (select d.path, min(d.lengthroad) as lengthroad
12  from
13  (select path,sum(ROADSECTLENGTH) as lengthroad
14  from
15  (select abs(num1-num2) as path,b.*
16  from (select level as num1,rownum as num2,a.*
17        from road a
18        where ENDCROSSINGID<=5
19        and    STARTCROSSINGID>=1
20        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) c
21  group by path) d,
22  (select abs(num1-num2) as path,b.*
23  from (select level as num1,rownum as num2,a.*
24        from road a
25        where ENDCROSSINGID<=5
26        and    STARTCROSSINGID>=1
27        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) e,
28  (select abs(num1-num2) as path,b.*
29  from (select level as num1,rownum as num2,a.*
30        from road a
31        where ENDCROSSINGID<=5
32        and    STARTCROSSINGID>=1
33        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) f
34  where d.path=e.path
35  and e.STARTCROSSINGID=1
36  and  d.path=f.path
37  and f.ENDCROSSINGID=5
38  group by d.path) y,----------------------------------------------------------
39  (select min(d.lengthroad) as lengthroad
40  from
41  (select path,sum(ROADSECTLENGTH) as lengthroad
42  from
43  (select abs(num1-num2) as path,b.*
44  from (select level as num1,rownum as num2,a.*
45        from road a
46        where ENDCROSSINGID<=5
47        and    STARTCROSSINGID>=1
48        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) c
49  group by path) d,
50  (select abs(num1-num2) as path,b.*
51  from (select level as num1,rownum as num2,a.*
52        from road a
53        where ENDCROSSINGID<=5
54        and    STARTCROSSINGID>=1
55        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) e,
56  (select abs(num1-num2) as path,b.*
57  from (select level as num1,rownum as num2,a.*
58        from road a
59        where ENDCROSSINGID<=5
60        and    STARTCROSSINGID>=1
61        connect by prior ENDCROSSINGID=STARTCROSSINGID) b) f
62  where d.path=e.path
63  and e.STARTCROSSINGID=1
64  and  d.path=f.path
65  and f.ENDCROSSINGID=5) z----------------------------------------------------------
66  where x.path=y.path
67  and   y.lengthroad=z.lengthroad;
ROADSECTID
         1
         4
SQL> Replace 1 and 5 by parameters...
Good luck
Nicolas.

Similar Messages

  • Implement ETL using PL SQL

    Hi,
    I want to implement ETL using Pl Sql code. The input data is in the form of XML file. Can u just guide me in coding an efficient ETL using pl sql.

    http://www.appsassociates.com/resources/bi-resources/Reading_XML_Data.pdf

  • Keyboard short cut problems

    I updated my Mac and everything was fine until i had to restart it. My Photoshop's keyboard short cut became all random like this:
    I tried restarting my computer again but it has not changes. The most weird part is that when i tried to change the short-cuts, it won't work even though i clicked on accept and "ok". Is there a way i can turn this back? It wasn't like this when i first got this back at November.

    quote from:
    https://discussions.apple.com/message/23471905#23471905
    1) While in Photoshop, go to 'Keyboard Shortcuts' under the 'Edit' menu in the Mac's menu bar. The 'Keyboard Shortcuts and Menus' panel opens.
    2) With the 'Keyboard Shortcuts' tab selected (as opposed to 'Menus'), double-click 'File' (has a triangle next to it) under the 'Application Menu Command' and select/highlight the 'Open...' command.
    3) Without editing the key shortcut in any way, click the 'Accept' button to the right. Then 'Okay' to close the panel. This successfully reinstates the 'Open' keyboard shortcut.
    4) At this point, you're probably thinking, 'My god, I'm going to have to repeat this process for every single keyboard shortcut...'. But no, simply 'accepting' the 'Open' command appears to successfully reinstate every other keyboard shortcut too!

  • Short cut problem

    I am using lightroom (vers: 3.6) for the first time and love it but I seem to have a problem with th image zoom short cut Ctrl - plus. Basically nothing happens. Ctrl - minus is fine and reducess the image down too it's minimum size in stages (and the zoom bar moves accordingly). It's a small thing but a really useful short cut. Any ideas? Both keyboard short cuts work OK in my browser window for zooming. I use a wacom tablet with the mouse set to pen mode which is not a problem in other programs.

    This works ok for me, using the main keyboard. If I us Ctrl + on the numeric keypad, it doesn't work. Ctrl - works in both places.
    Interestingly, Victoria Bampton's list of all know keyboard shortcuts lists Zoom as Ctrl =. The equal key is really the unshifted +. I'm not saying that Adobe have done the right thing here, but there it is. The spacebar and Z key also zoom, so you have lots of choices--just not the one you want.
    Hal

  • Problem Dropping Objects in Oracle XE using PL/SQL Developer

    Hi all,
    I am using PL/SQL Developer to access Oracle XE. I created some tables and later dropped them. But I still see some objects in the PL/SQL Developer Browser under the Tables section.
    Below is the name of the objects in I see:
    bin$fj7zj7y9rhqujmwrz1zmtg==$0,
    bin$frxjknkot4cwtkexm4wtca==$0,
    bin$q2m8wls+s72szfufb+mnzw==$0,
    bin$syrcyj1bsqcelpfsodudrw==$0,
    bin$tjt8ipk6ras8qtx0zvn+6w==$0,
    bin$vc6dzazorg6zwemticqdha==$0,
    bin$xfrxhcb3s5ev8wkjfc/3vg==$0,
    bin$oyrdsi+us+yhhoprzdingq==$0,
    bin$vtk7saqqtecbhmdwpnp1bg==$0,
    bin$x1hhdhy+trmfponyldjwdw==$0
    When I tried dropping these objects, I get ORA - 00933: SQL Command not properly ended. Error deleting bin$fj7zj7y9rhqujmwrz1zmtg==$0
    How do I resolve this problem? And then drop all those objects listed above.
    Is it possible to drop those objects at all?
    Thanks in advance.
    Sam.

    There is no problem sofar. The objects you see are dropped objects ( if you drop it, oracle silently rename the object but preserve it as long you have sufficient space ).
    You shouldn't drop them if you don't have issue with free space - they enable you to get back accidentally dropped table without to have restore the backup ( flashback table). If you are annoyed by displaying it in PL SQL Developer, you can just add a filter to not show them to you ( all objects like 'bin%' ) or you can update to newrer version of PL SQL Developer ( i've 7.0.0.1050 and it is displayed properly, all dropped objects can be found under recyclebin folder ). Finally , if you want purge them, use the 'purge recyclebin' command.
    Best regards
    Maxim

  • Can I create a file using pl/sql code in application server ?

    Hi
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
    Please help me with an example...in this regard
    Regards
    Sa

    864334 wrote:
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
    Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
    The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
    If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
    In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

  • I need a list of keystrokes/short cuts; where can I find this?

    I am new to Mac and know a few keystrokes, but want to learn more.
    Where can I go to find a comprehensive list?
    Thanks!
    Noelle

    Noelle
    Here's another option... http://docs.info.apple.com/article.html?artnum=75459
    Take note of the "Related Documents" at the bottom of the page.
    Jim

  • Short Cut Key for Personalized menu

    Hi
    I've created an Menu for the zoom function using personalization, Is it possible to setup a short key for the menu created
    Example: for the File menu we can use Alt+F similarly is it possible to build the short cut key for the custom menu created using personalization
    Please advice
    thanks
    Regards
    Ramesh Kumar S

    The Character '&' worked very well as expected...
    Thanks a lot
    Regards
    Ramesh Kumar S

  • Moving "Back" using short-cut keys

    I am running Safari 3.0.2 on both Mac and PC with no probs .. but I do have a "right" hand vs "left" hand suggestion. Currently, to use a short-cut key to move back on page when browsing you must press CNTL [ .. which is great if your "left" handed and use a mouse or glidepad with your left hand and right hand is free .. but, if your use a mouse or glide pad with your right hand you can't use your left hand to go back using a short-cut key .. on Opera browser they use the "z" key to go back one page so you can be mousing with one hand and navigating with the other. So .. it would be nice if the Safari developers made a way to select your custome back page short-cut key ... Thanks.

    smitz,
    Welcome to Apple Discussions.
    Since this is a user-to-user forum your comments will probably not be made available to any Safari development team. I believe that you could use the Safari>"Report Bugs to Apple" selection from the Safari Menu to make that recommendation.
    I can go back a page using Safari in my hardware setup by using the "delete" key. I am not sure that will work on your keyboard. You may also have to use the fn key.
    ;~)

  • OBIEE 10g - Can I use logical SQL to set variable?

    I am trying to set value of a session variable in the Advanced tab Prefix box of a request.
    Assigment of absolute value like this is working good:
    SET VARIABLE MYVAR=1;
    Can I set the variable using logical SQL? Something like:
    SET VARIABLE MYVAR = (SELECT table1.col1 from catname where table1.col2=1)
    Thanks in advance.

    Hi,
    You can create a session variable or dynamic variable in the RPD and try using it in here at the Advanced Tab prefix.
    But still check yourself if you need multiple values returning in the SQL statement.
    Hope this is helpful/ useful.
    Regards
    MuRam

  • I have lost all my bookmarks and screen short cuts since the outside telstra cable was damaged and repaired. How can I get them back?

    my internet had been running slowly with lots of fizz and crackle on the line. Telstra came and fixed it, necessitating my having to reset the modem. At first boot up after that, all screen short cuts were gone and all bookmarks were gone. Can I get them back? Help!!

    Hello,
    Please confirm that the problem you faced was this
    #You had an issue with our Internet access
    #Telstra fixed the issue and restarted your modem
    #Now in Firefox you are unable to view your bookmarks
    Is that the issue? If so, it is unlikely that a connectivity issue has caused this problem. Also, can you please confirm if you have enabled Firefox Sync?
    Thank you

  • How can I synchronize Photoshop short cuts with a second Mac?

    Hi there,
    since Photoshop CC 2014 (Version June 2014) Photoshop is supposed to synchronize short cuts via the cloud but it does not and there is no option to do so in the sync preferences. Is this a bug, do I miss something and how can I solve the problem?
    Thanks – matias
    (MacBook Retina 2013 and iMac 2013, latest Yosemite, latest Adobe CC on both)

    Workspaces can be synced in CC 2014.2.2  I was able to upload my settings from my CC 2014 Mac and download them to CC 2014 Windows.
    Keyboard Shortcuts and Menus are saved as part of a Workspace, not by themselves.
    So you would save it as My Custom Workspace, and check keyboard shortcuts and menus in the save workspace dialog.
    You can also use Edit > Presets > Export/Import Presets
    Gene

  • When I login on my When I sign in to a site on my ipad using my email address as ID a short cut of my email address comes up. How can I get rid of it?

    When I sign in to a site on my iPad using my email address as ID a short cut of my email address comes up. How can I get rid of it?

    You can edit keyboard shortcuts in Settings>General>Keyboard>Shortcuts>Edit.

  • Can't use down key because it opens automator. Does any one know how to disable this short cut?

    Everytime I press down on down key it opens automator. It doesn't let me delete the app. I don't know what to do, it is very frustating to fill in a chart when I can't use the down key. Does any one know how to disable this short cut?

    Are you talking about the Down Arrow key? To my knowledge there is no way to use that key as a shortcut for anything. But look in the Keyboard section of System Preferences and the Keyboard shortcut tab.

  • Can I create a short cut on the home screen to accessibility settings on an ipad

    Hi, have a partially sighted sister who uses an iPad, is there an easy way for her to switch between voice over on/off and white on black? without having to go into settings and then scroll down to the appropriate menu
    thanks

    Patrick Duncan wrote:
    Can I create a short cut on the home screen to accessibility settings on an ipad
    Patrick ~ Yes, see this post:
    Shortcut to Bluetooth Settings
    ...For quick access to Accessibility settings, set up the shortcut icon with this URL(Homepage) — case sensitive:
    prefs:root=General&path=ACCESSIBILITY

Maybe you are looking for