Looping Queries in Oracle using data from SQL Server

5 pts.
Tags:
Oracle development
Oracle queries
SQL
SQL queries
SQL Server connectivity
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Are you doing this on Oracle or Sql Server ? what version ?
    68,035 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following