5 pts.
 Looping Queries in Oracle using data from SQL Server
I have a table of entries from SQL server called PID. Each of this entry should follow the following select * from HR.TABLES a START WITH a.SID = '0' CONNECT BY PRIOR a.parentid = a.sid' Where I have '0' in the query above, should take all the values from PID. Is there a easy way to write this? or should I loop through the query like foreach ( value from arraylist) { select * from HR.TABLES a START WITH a.SID = 'value' CONNECT BY PRIOR a.parentid = a.sid' } IN short I need to do something like above and I am really tired thinkin about it for past 2 days. Please help . THanks in advance

Software/Hardware used:
ASKED: February 28, 2009  4:05 PM
UPDATED: March 2, 2009  8:36 PM

Answer Wiki:
Are you looking for a self join? <pre>SELECT a.* FROM HR.TABLES a JOIN HR.TABLES b ON a.parentid = b.sid WHERE a.sid = 'value'</pre>
Last Wiki Answer Submitted:  March 1, 2009  8:29 am  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Are you doing this on Oracle or Sql Server ? what version ?

 63,535 pts.