CONNECT By Prior...or something else...
I have a very simple audit table with the following format:
Input_File Varchar2(256)
Output_File Varchar2(256)
Date
The table basically keeps tracks of files going through my systems. At a later point in processing, what was an Output_File for record 1, can be the Input_File of record two. If a single Input_File generates several output files, then a second branch would be generated based upon that output file name. Here are a few example records - I have only shown an example of only 1 branch:
Row Input_File Output_File
1 RWMS.00024928.DAT RWMS.00024928.DAT
2 RWMS.00024928.DAT 943RWMS.00024928.DAT
3 943RWMS.00024928.DAT CA943RWMS.00024928.DAT.presort
4 CA943RWMS.00024928.DAT.presort CA943RWMS.00024928.DAT
(I have intentionally left Date out of this example.)
What I am trying to do is find the first Input_File with an associating Output_File. When I need this information, it will be based upon the final output filename; which in this case is the file CA943RWMS.00024928.DAT. So, in this case the orignal input filename is RWMS.00024928.DAT.
Currently, I am using the option 'CONNECT BY Prior' to link Input_File of row 4 to Output_File of Row 3 and so on. This works OK when there are not too many records in the table. However, when the table gets pretty big, the query takes longer and longer to run.
Is there a more efficient method than using 'CONNECT BY Prior'? If so, how would I go about writing the SQL to do that?
Regards,
Richard.
Faheem1 wrote:
FATHER, CHILD_NUM, CODE, CODE_QTY
a 1 b 1
b 1 c 1.5
c 1 d 2
d 1 e 1
There are 3 columns father,child_num,code & the code_quantity.
It is explained as 'a' is my FINAL finished good and is produced from raw material 'b' using 1kg.
and here 'b' becomes my finished good and is produced from raw material 'c' using 1kg.
and here 'c' becomes my finished good and is produced from raw material 'd' using 1kg.
and here 'd' becomes my finished good and is produced from raw material 'e' using 1kg.how much of 'a' is produced from raw material 'b' using it 1 kg? is it 1 kg itself....??
And also what values 1,1.5,2.1 specify in above table...
If everything is 1:1 is product:rawmaterial ratio then 20kg of 'a' requires 20 kg of 'e'
Ravi Kumar
Edited by: ravikumar.sv on Nov 6, 2009 1:38 PM
Similar Messages
-
My mom put my ipod 5th gen in the house somewhere and it was turned off. It is connected to the internet in the house. How do i turn it on with the Findmyiphone or something else? It was an expensive gift and we can't find it now! Please help! How do i turn it on without finding it because she can't remember where it was.
That is so dumb...Apple is the best and most techinological company IN THE WORLD and they don't have the time to invent something like that? HUH? All they are worried about is making the "Worlds best Phone" and they can't take the time out to help their users or anybody that has their products. All they have is "Find mt Iphone" Well they should step up and do something else to help people like me out. Find a way to turn it on and you can find it or find a way to turn it on remotely.
Thank you for your replys -
I cannot connect to the internet after switching providers. I've changed the email address associated with the new account but am sure there is something else I need to change. I have also changed the apple information as well including user name and password. Can anyone help me? (This is an ipad question).
Apple ID: Changing your Apple ID
http://support.apple.com/kb/ht5621
Using your Apple ID for Apple services
http://support.apple.com/kb/HT4895
Apple ID: What to do after you change your Apple ID
http://support.apple.com/kb/HT5796?viewlocale=en_US&locale=en_US
iTunes Store: Associating a device or computer to your Apple ID
http://support.apple.com/kb/ht4627
iOS: Changing the signed-in iTunes Store Apple ID Account
http://support.apple.com/kb/ht1311
Some things to try first:
1. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
2. Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
3. Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at
http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
4. Go into your router security settings and change from WEP to WPA with AES.
5. Renew IP Address: (especially if you are drooping internet connection)
• Launch Settings app
• Tap on Wi-Fi
• Tap on the blue arrow of the Wi-Fi network that you connect to from the list
• In the window that opens, tap on the Renew Lease button
6. Potential Quick Fixes When Your iPad Won’t Connect to Your Wifi Network
http://ipadinsight.com/ipad-tips-tricks/potential-quick-fixes-when-your-ipad-won t-connect-to-your-wifi-network/
~~~~~~~~~~~~~~~~~~~~~~~~~
Fix WiFi Issue for iOS 7
http://ipadnerds.com/fix-wifi-issue-ios-7/
iOS 6 Wifi Problems/Fixes
Wi-Fi Fix for iOS 6
https://discussions.apple.com/thread/4823738?tstart=240
How To: Workaround iPad Wi-Fi Issues
http://www.theipadfan.com/workaround-ipad-wifi-issues/
Another Fix For iOS 6 WiFi Problems
http://tabletcrunch.com/2012/10/27/fix-ios-6-wifi-problems-ssid/
Wifi Doesn't Connect After Waking From Sleep - Sometimes increasing screen brightness prevents the failure to reconnect after waking from sleep. According to Apple, “If brightness is at lowest level, increase it by moving the slider to the right and set auto brightness to off.”
Fix For iOS 6 WiFi Problems?
http://tabletcrunch.com/2012/09/27/fix-ios-6-wifi-problems/
Did iOS 6 Screw Your Wi-Fi? Here’s How to Fix It
http://gizmodo.com/5944761/does-ios-6-have-a-wi+fi-bug
How To Fix Wi-Fi Connectivity Issue After Upgrading To iOS 6
http://www.iphonehacks.com/2012/09/fix-wi-fi-connectivity-issue-after-upgrading- to-ios-6.html
iOS 6 iPad 3 wi-fi "connection fix" for netgear router
http://www.youtube.com/watch?v=XsWS4ha-dn0
Apple's iOS 6 Wi-Fi problems
http://www.zdnet.com/apples-ios-6-wi-fi-problems-linger-on-7000004799/
~~~~~~~~~~~~~~~~~~~~~~~
iPad: Issues connecting to Wi-Fi networks
http://support.apple.com/kb/ts3304
How to Boost Your Wi-Fi Signal
http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Boost-Your-Wi-Fi-Signal.hmL
Troubleshooting a Weak Wi-Fi Signal
http://ipad.about.com/od/iPad_Troubleshooting/a/Troubleshooting-A-Weak-Wi-Fi-Signal.htm
How to Fix a Poor Wi-Fi Signal on Your iPad
http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Fix-A-Poor-Wi-Fi-Signal-O n-Your-iPad.htm
iOS Troubleshooting Wi-Fi networks and connections http://support.apple.com/kb/TS1398
iPad: Issues connecting to Wi-Fi networks http://support.apple.com/kb/ts3304
WiFi Connecting/Troubleshooting http://www.apple.com/support/ipad/wifi/
How to Fix: My iPad Won't Connect to WiFi
http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-My-Ipad-Wont-Connect -To-Wi-Fi.htm
iOS: Connecting to the Internet http://support.apple.com/kb/HT1695
iOS: Recommended settings for Wi-Fi routers and access points http://support.apple.com/kb/HT4199
How to Quickly Fix iPad 3 Wi-Fi Reception Problems
http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
iPad Wi-Fi Problems: Comprehensive List of Fixes
http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
Connect iPad to Wi-Fi (with troubleshooting info)
http://thehowto.wikidot.com/wifi-connect-ipad
10 Ways to Boost Your Wireless Signal
http://www.pcmag.com/article2/0,2817,2372811,00.asp
Fix iPad Wifi Connection and Signal Issues http://www.youtube.com/watch?v=uwWtIG5jUxE
Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
How To Fix iPhone, iPad, iPod Touch Wi-Fi Connectivity Issue http://tinyurl.com/7nvxbmz
Unable to Connect After iOS Update - saw this solution on another post.
https://discussions.apple.com/thread/4010130
Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
Some Wi-Fi losses may stem from a problematic interaction between Wi-Fi and cellular data connections. Numerous users have found that turning off Cellular Data in Settings gets their Wi-Fi working again.
You may have many apps open which can possibly cause the slowdown and possibly the loss of wifi. In iOS 4-6 double tap your Home button & at the bottom of the screen you will see the icons of all open apps. Close those you are not using by pressing on an icon until all icons wiggle - then tap the minus sign. For iOS 7 users, there’s an easy way to see which apps are open in order to close them. By double-tapping the home button on your iPhone or iPad, the new multitasking feature in iOS 7 shows full page previews of all your open apps. Simply scroll horizontally to see all your apps, and close the apps with a simple flick towards the top of the screen.
Wi-Fi or Bluetooth settings grayed out or dim
http://support.apple.com/kb/TS1559
~~~~~~~~~~~~~~~
If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
Cheers, Tom -
On some pages the text from more than one paragraph stack up on top of each other, like writing something then writing something else over the top of it. Some pages will run text and pictures together, like a car rear-ending another or a train pile up. Other pages will cut an image or text short, i.e. it will display a portion of the top of the image or text but not the rest. This happens on Amazon for example, the section where it says "Customers who looked at this also looked at" will allow only a certain amount of the upper portion of the description immediately below the picture of the product but below that section everything is fine until I get to another section displaying more products and their descriptions and then it cuts the bottom portions off again. I've noticed this behavior mostly in the sections with product photos, the text sections seem okay. YouTube also displays this behavior. It's even doing it on this page right now. Below this box I can read "The more information you can provide the better chance your question will be answered " , but directly below that in the next sentence I can see the start of it with "Troublshootin" and the "Automatically Add" in a green field covering the "g". The next clear text is "A window will open in the top corner. Click Allow, and then click Install. If the automated way doesn't work, try these manual steps." I tried turning of pre-fetching, clearing history, cookies, and cache, scanning for malware with Avast and Windows Defender all to no avail. It began when I upgraded from dial up to DSL via AT&T Uverse. I have a Motorola NVG510 modem. The modem was replaced an hour ago along with new dedicated lines and DSL/Phone splitter from the box by an AT&T technician to make sure my incoming lines were up to par. He ran a connection test and verified everything is up to standards. IE does not display this behavior. I am running Firefox20.0.1 and all previous versions have acted the same way since I upgraded to DSL about 3 months ago.
If you have increased the minimum font size then try the default setting "none" in case the current setting is causing problems.
*Tools > Options > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
Make sure that you allow websites to choose their fonts.
*Tools > Options > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above"
It is better not to increase the minimum font size, but use an extension to set the default page zoom to prevent issues with text not being displayed properly.
You can use an extension to set a default font size and page zoom on web pages.
*Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/
*NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/ -
I just got iphone 5c and i am not happy with it. It uses to much data and i don't even know how. I can't get the ringtones i want for my contacts.I got it on my free upgrade but i want to take it back and get something else but where i got it they say i can't because i don't have the earbuds and i have serches or them. now i am suck with a phone i don't like at all until my next upgrade. this is very dishearten
1. If you are this unhappy with that phone, and the lost earbuds is the only thing stopping you from taking it back, why do not just buy some earbuds. That way you can get rid of that phone. It all depend upon how much you want to get rid of that phone.
2. Yet if you are stuck with that iPhone, here is something might help you to control the data usage. By design, iPhones do turn off WiFi when they go dormant. So if a download is in progress and so forth when the phone goes dormant, it will switch to use cellular data, if this setting is left on. Therefore, from multi-sources I have learned that if you keep your iPhone connected to a power source, then it will stay connected to the available WiFi. -
How can I change the BlackBerry Link Network Drive mapping from Z: to something else?
Hello,
I generally have a mapping to my NFS server on Z:, and my iTunes library has a relative path to Z: for all of my music - the fact that Link is automatically picking Z: as my network sync target for my device does not work for me to sync music, or anything really. I can't figure out how to change this value to something else.
I found the registry key: \HKEY_CURRENT_USER\Software\Research In Motion\Device Manager\Device Settings\<DEVICENAME>\VolumeMapping with a default blank REG_SZ - can I use this key at all to manually change drive mappings for my device? If so, what is the key/value pair I need and will this mess up any assumptions taken inside the Link software for synching?
... Also, I have a Feature Enhancement Request to go along with this issue: Add a "Change drive map letter" button beside the "Turn on wireless connections to my computer" button in Link, and add the same option in the context menu to the 'Device Manager' for the mapping (which currently just says 'Explore').
Thanks for the help,
- JeffI do not know a lot about this subject but since Device Manager is not a Device and the BlackBerry Phone is not recognized as a Device in Disk management unless Mass Storage is turned ON it looks as if by design you cannot change the Drive Letter.
Also if Mass Storage is turned On in the Phone Settings File Manager and BB link will not work but the BB Phone will then be recognized as a Device in Disk Management and the Drive Letter can be changed, this has no effect on the Drive Letters for Device Manager.
Normally to change the Drive Letter and Paths of a Device once the Device is plugged you would go to Administrative Tools, Computer Management, Disk Management, right click the Device and choose "Change Drive Letter and Paths"
Changing the Registry or Uninstalling Device Manager but keeping BB Link or looking for a Utility that can change the Drive Letter such as the one that many XP users had called TweakUI (only worked in XP) or changing the Drive Letter for your Network may be the only way. -
How to test if MDD power supply is bad or it's Something Else
Ok,
I've had a MDD for 4 years. Dec 2007 the PSU died. I had it replaced under my renter's policy (yeah..) the new rev. part was $870!. I Didn't care... insurance paid for the repair.
Now, after 1.5 years, I was having disk corruption issues which led to numerous forced shutdowns (no reset button on the MD) finally, after about 5 of these in one day, the power on light lit when pressed, and I heard a crackle & smelled a a bit of smoke. I pulled the power cord immediately.
btw pressing the power button now did nothing at all, no "fan attempts" no crackle.. nothing.
Same deal, I called the ins co, took MDD to the authorized techs, who checked & said the PSU was dead... again.
The Ins Co. is "totaling" the MDD and I'm looking for a used G5.
BUT! I'd love to get the MDD working again. Just to have it as a second machine.
I've read a bunch of threads here on this issue & testing the PSU.
I'm not a super geek, but I can follow instructions... which I did. There's a great online instruction set with pics and all, about how a guy found a bad solder by disassembling the PSU.
I followed it step by step. Saw nothing remarkable.
Then I came here looking for steps to test the PSU (I'm starting to wonder if it's more than that).
I found a diagram of the pins and voltages.
Connected the PSU the the juice and started testing the connector, where it plugs into the motherboard.
Here's what I found (connected to power but obviously still not starting the computer):
Pin 1 (says +5volts sb, which I assume means stand by?) with the black lead from the tester inserted into pin 2 (gnd). It read 5 Volts.
No other pins showed ANY voltage EXCEPT pin 14 (which says +25Vsb). That read +24.8V when tested.
What I DON'T know is...
If disconnected from the MDD, should all the pins read voltage as the pinout diagram says? I'm brand new to this level of diagnosis.
I'm wondering if maybe the CPU fried etc.
Also, while trying to determine if the power button might be faulty I broke the switch off (duhh). Shorting across the two stubs that were left there didn't produce any powerup either (it's just a 2 pin contact switch right?)
So I need to know if I have accurately found the PSU to be bad. I can get one on ebay for $150-ish.
But I'm worried, since this was a +*new super better PSU*+ and it (possibly) has died, maybe something on the motherboard etc. isn't right.
The machine hasn't been connected to power for 3 weeks & yes, the battery is now dead. I swapped it out, and reconnected the PSU... nothing.
+*So first, did I correctly test the psu?*+
there was a dead link to a MDD repair manual on another thread. First I have to figure out IF the psu is dead, and then decide if something else KILLED it.
Help? I'm using wife's G4 and she's getting real PO'd after 3 weeks!
Thanks to anyone in advance.
TomHi,
Thanks. By power button board, Do you mean the unit that has the power button on it? On the case front?
If so, I mentioned the switch broke while I was testing. I guess to continue I have to get a new switch.
I will pull the mini-board for the power button though to look for signs of damage.
Can I get a new switch to solder on to the board, if the board looks good. The orig. switch physically broke off the board. It's a standard contact switch correct? i.e. press and there should be continuity between the two pins? I'll pull the board as well.
I've already checked the PSU interior. No burnt wires visible anywhere. There's a lot of grey goo glue used so it's hard to see, but since the PSU passed the two passive power tests you mentioned, are we for now assuming it is a good PSU?
Other discussions I've read, describe continuing to test different pins and look for appropriate voltages. That doesn't make sense to me with the computer not starting up.
Aren't the rest of the voltages supposed to show ONLY after the command to supply startup power is given (by the power switch)?
Processor "looks" good too, no signs of burnt anything after pulling the heat sink, but I haven't removed the logic board or the mother board yet to look underneath. -
Hey guys!
i just bought a copy of ProTools 11 and it gave some recommendation on changing your default Mac settings to make ProTools run at its peek performance, for example it says to turn on wifi and wired ethernet connection. There at quite a few of these recommendations. I dont want to change each individual setting every time i use ProTools. Is there something i can run that will change all of these setting to the recommendations. Then run something else to turn all of these setting back to default? thanks!
God bless,
JoshuaIs your iMac running okay? Where are you getting this update from? Especially if it is an e-mail, I would not do what the 'update' is suggesting.
Your profile shows you are running Mavericks. If everything is okay, then it would appear to me you don't need to download something to run Mavericks. -
I listen to a lot of live performances (house sets that are from 1 hour to 3 hours long) when I start to listen to a set and then stop to do something else on the iPhone when I go back to start to listen to the track it has started from the beginning.
It sounds like either your hard drive or the SATA cable that connects it to the motherboard are failing. This could be heat related in your case, which is why you see it after it runs awhile. You can take it to the Genius Bar for a free evaluation. If you decide to test it yourself, I usually suggest moving the hard drive to an external enclosure. If it works there for awhile, the cable is probably the issue.
http://www.amazon.com/Sabrent-2-5-Inch-Aluminum-Enclosure-EC-TB4P/dp/B005EIGUD4/ ref=sr_1_3?ie=UTF8&qid=1397647657&sr=8-3&keywords=2.5+enclosure
http://www.ifixit.com/Device/MacBook_Pro_13%22_Unibody_Mid_2009 -
This 9i SQL Reference indicates that it is possible to combine CONNECT BY PRIOR with a join predicate.
In 8i I get the following error:
ORA-01437 cannot have join with CONNECT BY
Cause: A join operation was specified with a CONNECT BY clause. If a CONNECT BY clause is used in a SELECT statement for a tree-structured query, only one table may be referenced in the query.
Action: Remove either the CONNECT BY clause or the join operation from the SQL statement.
I can't find documentation to test the obvious hypothesis - comments?My alternative solutions.
***Sample***
ID PrevID
1 null
2 1
3 1
4 3
***output which we want***
ID PrevID isLeaf
1 null 0
2 1 1
3 1 0
4 3 1
***DDL***
create table CloneIsLeaf as
select 1 as ID,null as PrevID from dual
union select 2,1 from dual
union select 3,1 from dual
union select 4,3 from dual;
--method1
select ID,PrevID,
case when exists(select 1 from CloneIsLeaf b
where a.ID = b.PrevID) then 0 else 1 end as isLeaf
from CloneIsLeaf a
Start With ID = 1
connect by prior ID = PrevID;
--method2
select ID,PrevID,
case when Level < Lead(Level) over(order by RowNum)
then 0 else 1 end as isLeaf
from CloneIsLeaf
Start With ID = 1
connect by prior ID = PrevID;
--method3
select ID,PrevID,
case when LV < Lead(LV) over(order by RowNum)
then 0 else 1 end as isLeaf
from (select ID,PrevID,Level as LV
from CloneIsLeaf
Start With ID = 1
connect by prior ID = PrevID
order siblings by ID);
--method4
select ID,PrevID,
case when LV < Lead(LV) over(order by Row_Num)
then 0 else 1 end as isLeaf
from (select ID,PrevID,LV,RowNum as Row_Num
from (select ID,PrevID,Level as LV
from CloneIsLeaf
Start With ID = 1
connect by prior ID = PrevID
order siblings by ID));on method2 and method3 and method3,
I used that "Hierarchical Queries" is depth-first search (http://en.wikipedia.org/wiki/Depth-first_search)
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/queries003.htm#i2053935
my site :-)
http://www.geocities.jp/oraclesqlpuzzle/10-149.html -
Connect by prior by speific order problem.
Oracle: 10.2.0.4
I have a table containing events backup.
i want to list the hierarchy within that backup oreder by the time_stamp for all levels.
create table BCK_EVENTS
bck_backup_id NUMBER(9) default 0 not null,
event_id NUMBER(15) default 0 not null,
event_name NVARCHAR2(100) default ' ' not null
time_stamp NUMBER(9) default 0 not null,
parent_event NUMBER(15) default 0 not null,
add constraint BCK_EVENTS_PK primary key (BCK_EVENT_ID, EVENT_ID); // event_id is not unique can be under one or more backup id'sthis is not a tree with one root, there is more than one event in the root level (level 1).
example:
Event Name Time level <- time is numeric but for easier reading.
*Event A 10:00 1
*Event C 10:30 2
*Event B 11:17 3
*Event H 12:10 1
*Event J 12:10 2
*Event M 12:21 2
*Event Z 15:33 1
*Event R 16:56 2
*Event M 16:57 3
*Event G 20:20 2What i tried was :
select lpad( '*', level*2 ) || event_id,event_name,time_stamp,parent_event,level from bck_events
where bck_event_id=100031
start with parent_event is null
connect by prior event_id = parent_eventand there are two problems with it.
1. it's not ordered even when i added an Index (parent_event,time_stamp) and try to hint it.
2. it returns loads of multiple rows.
hope it's clear enough. I thank for any help.
Edited by: 973065 on Nov 25, 2012 8:04 AM
Edited by: 973065 on Nov 25, 2012 9:23 AM
Edited by: 973065 on Nov 25, 2012 9:29 AM
Edited by: 973065 on Nov 25, 2012 9:31 AMHi,
973065 wrote:
Oracle: 10.2
I have a table containing events backup.
i want to list the hierarchy within that backup oreder by the time_stamp for all levels.
create table BCK_EVENTS
bck_backup_id NUMBER(9) default 0 not null,
event_id NUMBER(15) default 0 not null,
event_name NVARCHAR2(100) default ' ' not null
time_stamp NUMBER(9) default 0 not null,
parent_event NUMBER(15) default 0 not null,
Thanks for posting the version number and the CREATE TABLE statement. Don't forget to post INSERT statements for your sample data.
add constraint BCK_EVENTS_PK primary key (BCK_EVENT_ID, EVENT_ID); // event_id is not unique can be under one or more backup id's
this is not a tree with one root, there is more than one event in the root level (level 1).Is it a forest, that is, a set of trees?
example:
Event Name Time level <- time is numeric but for easier reading.
*Event A 10:00 1
*Event C 10:30 2
*Event B 11:17 3
*Event H 12:10 1
*Event J 12:10 2
*Event M 12:21 2
*Event Z 15:33 1
*Event R 16:56 2
*Event M 16:57 3
*Event G 20:20 2
That seems to be a forest, that is, every row has 0 or 1 parent, and no row is its own ancestor.
What i tried was :
select lpad( '*', level*2 ) || event_id,event_name,time_stamp,parent_event,level from bck_events
where bck_event_id=100031
start with parent_event is null
connect by prior event_id = parent_event
and there are two problems with it.
1. it's not ordered even when i added an Index (parent_event,time_stamp) and try to hint it.Depending on your data, you may just need to add
ORDER SIBLINGS BY time_stampat the end, after the CONNECT BY clause.
If you need rows sorted by time_stamp under their roots, but otherwise without regard to the hierarchy, then use CONNECT_BY_ROOT.
2. it returns loads of multiple rows.Again, it depends on your data. I'll bet you need something more in the CONNECT BY clause, but I can't tell what without some sample data and an exxplanation of how you gett the results you posted from that data. The fact that bck_event_id is part of the primary key makes me suspect that maybe bck_event_id needs to be somewhere in the CONNECT BY clause, but that's just a wild guess.
hope it's clear enough. I thank for any help.As mentioned before, see the forum FAQ {message:id=9360002} -
Hi, I have following problem
Table TMP contains following data
ID PID
1
2 1
3 2
select t.id
from tmp t
where level=(select max(level)
from tmp t2
connect by prior t2.pid=t2.id
start with t2.id=&ID)
connect by prior t.pid=t.id
start with t.id=&ID
Select returns 1 when ID=3
Is there a way to write select so that it returns value for first node
and value of ID used in select?
Something like
select value_of_ID
,t.id
from tmp t
start with t.id=&ID
so I could use group by on first column (group by value_of_ID)
Following select would not satisfy:
select &ID
,t.id
from tmp t
start with t.id=&IDI would suggest something more straightforward:
select :startnode, id
from tmp
where pid is null
start with id = :startnode
connect by prior pid = id;The WHERE clause will limit the result to just the top level - no need for a subquery or aggregate functions. -
Understanding multiple conditions in connect by prior clause Oracle
Hi ,
Can some one please explain me how to comprehend/understand multiple conditions in connect by prior conditions with some example data.
I am creating a table like this
CREATE TABLE FAMiLY_TREE
GRAND_FATHERID number,
FATHER_ID number,
SON_ID number,
person_name varchar(20)
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(NULL, NULL , 5 , 'Mr X ' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(null, 5 , 6 , 'Dave' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(5, 6 , 7 , 'Vinny' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(5, 6 , 16 , 'Omy' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(5, 6 , 17 , 'Vijjy' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(6, 7 , 8 , 'Vicky' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(6, 7 , 9 , 'Varis' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(7, 8 , 10 , 'Vshnu' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(7, 8 , 11 , 'dyna' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(8, 10 , 14 , 'Marry' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(8, 10 , 15 , 'Mac' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(7, 9 , 12 , 'Garry' );
INSERT INTO FAMILY_TREE (GRAND_FATHERID ,FATHER_ID , SON_ID , PERSON_NAME ) VALUES
(7, 9 , 13 , 'Ganny' );
SELECT
LPAD(' ', LEVEL*3) || PERSON_NAME FROM FAMILY_TREE
START WITH SON_ID= 6
CONNECT BY PRIOR SON_ID = FATHER_ID
AND PRIOR FATHER_ID = GRAND_FATHERID ;
SELECT
LPAD(' ', LEVEL*3) || PERSON_NAME FROM FAMILY_TREE
START WITH SON_ID= 6
CONNECT BY PRIOR SON_ID = FATHER_ID ;
Both These query return the same o/p
Dave
Vinny
Vicky
Vshnu
Marry
Mac
dyna
Varis
Garry
Ganny
Omy
Vijjy
Can some one please explain me comprehension of both these query or give me a example where i can understand multiple connect by prior conditions
ThanksMaybe (something to play with)
with
family_tree as
(select 'Green' family,null ancestor,1 person,'Mr X' person_name,1900 born from dual union all
select 'Green',1,2,'Dave',1920 from dual union all
select 'Green',2,3,'Vinny',1940 from dual union all
select 'Green',2,4,'Omy',1945 from dual union all
select 'Green',2,5,'Vijjy',1950 from dual union all
select 'Green',3,6,'Vicky',1960 from dual union all
select 'Green',3,7,'Varis',1965 from dual union all
select 'Green',6,8,'Vshnu',1980 from dual union all
select 'Green',6,9,'Dyna',1985 from dual union all
select 'Green',8,10,'Mary',2000 from dual union all
select 'Green',8,11,'Mac',2005 from dual union all
select 'Green',7,12,'Garry',1985 from dual union all
select 'Green',7,13,'Ganny',1990 from dual union all
select 'Brown',null,14,'Joe',1950 from dual union all
select 'Brown',14,15,'Jim',1970 from dual union all
select 'Brown',14,16,'Joy',1975 from dual union all
select 'Brown',14,17,'Jay',1980 from dual union all
select 'Brown',16,18,'Jack',1995 from dual union all
select 'Brown',18,19,'Jake',2010 from dual union all
select 'Brown',18,20,'Jess',2012 from dual
select family,
root_name||' ('||to_char(root_born)||')' "(FA/MO)THER",
children
from (select family,
root_born,
root_name,
ltrim(sys_connect_by_path(person_name||' ('||to_char(born)||')',', '),', ') children
from (select family,
connect_by_root(person_name) root_name,
connect_by_root(born) root_born,
person_name,
born,
row_number() over (partition by family,connect_by_root(person_name) order by born) rn
from family_tree
where level = 2
connect by prior person = ancestor
where connect_by_isleaf = 1
start with rn = 1
connect by prior root_name = root_name
and prior family = family
and prior rn + 1 = rn
order by family desc,root_born
Regards
Etbin -
CONNECT BY PRIOR and performance of Query Plan
Anyone,
I have an SQL Statement that is performing rather slow and I am trying to figure out if I could optimize it. Here is the SQL:
SELECT/*+ index(MAXIMO.EQNDX99) */
maximo.equipment.eqnum, maximo.equipment.parent, LEVEL
FROM maximo.equipment@maxi_dblink
WHERE parent = :b1 CONNECT BY PRIOR eqnum = parent
ORDER BY eqnum, LEVELAfter some research in this board I followed some advice found to create an index on the table for both the eqnum, parent and the parent, eqnum. EQNDX99 and EQNDX999 respectivley.
Now the Qery Plan for this query shows the following:
SELECT STATEMENT (REMOTE)
SORT (ORDER BY)
FILTER
CONNECT BY
INDEX (FAST FULL SCAN) EQNDX99 (NON-UNIQUE)
TABLE ACESS (BY USER ROWID) EQUIPMENT
INDEX (RANGE SCAN) EQNDX999 (NON-UNIQUE)Now it appears to be using both indexes but it is operating through a DBLINK. Is there anything else I can do to increase performance??? It appears to be using the HINT through the link as well.
Thanks for any help I can get,
David Millerhow long does it takes to complete the query?
-
Connect by prior statement....
Hi,
please help me in the following query.
select a.part,a.assy
from assy_info a
connect by prior part = assy
start with assy in ('A');
part assy
B A
C B
Z C
H Z
I don't want the above query to extract after part = 'Z'.
please help me...
regards
laxmanI don't want the above query to extract after part = 'Z'.Hmm, something like:
SQL> select a.part,a.assy
2 from (
3 select 'B' part, 'A' assy from dual
4 union all
5 select 'C' part, 'B' assy from dual
6 union all
7 select 'Z' part, 'C' assy from dual
8 union all
9 select 'H' part, 'Z' assy from dual
10 ) a
11 connect by prior part = assy and prior part != 'Z'
12 start with assy in ('A');
P A
B A
C B
Z C?
Rgds.
Maybe you are looking for
-
TS3989 Photo Stream Photos not showing up on new phone
I bought the iPhone 5 and the photos in my Photo Stream on my iPhone 4 ard not all showing up on the new iPhone 5.
-
Did Leopard broke my built-in Airport?
My network connections have been buggy since the upgrade. My airport scanner (or whatever it's called) is failing to see all the wifi networks around me including my own AEBS. This usually happens after waking up from a sleep. I have to resort to a r
-
Font change when converting a Word File
I write documents using heading styles to automatically generate Tables of Contents, using Word 2003. When I convert the document to PDF, everything is normal. When I transfer the same file to my laptop, which uses Word 2007, and try to convert the
-
Sound click skip stutter mini 311
I upgraded my Hp Mini 311 from Win 7 Home Premium to Win7 Pro. Since then every audio track I have skips EXACTLY 20 seconds from the end of a track (just like a dirty cd) regardless of the track length. I'm also unable to restore the mini to factory
-
I am trying to edit an Indesign cs5 file a customer provided. However some how he used 25 spot colors when making this file. Thats even though he only really has three colors used in the design. So I am attempting to match some of his colors in order