Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recursive Java programming method for executing recursive SQL queries

 
Sk Balu
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody has a Java/JDBC example method to execute recursive SQL queries and print results? The method has to work for any number of queries and levels and the first query passes the parameter to the second query.

Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at common table expressions. I'm not sure if they are database specific, but I know postgres and SQL server both have them.
 
Sk Balu
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Take a look at common table expressions. I'm not sure if they are database specific, but I know postgres and SQL server both have them.


Thanks Jeanne. I looked at common table expressions but I am looking for Java recursive programming solution to make it database independant.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Java it's easier. Do the "parent" query and then call the same function with each result until no results are left. Just like any other Java recursion. You might try posting what you get stuck on.
 
Sk Balu
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:With Java it's easier. Do the "parent" query and then call the same function with each result until no results are left. Just like any other Java recursion. You might try posting what you get stuck on.


I am trying to write Java method but If this exists already then I can re-use it and save time.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sk Balu wrote:
Jeanne Boyarsky wrote:With Java it's easier. Do the "parent" query and then call the same function with each result until no results are left. Just like any other Java recursion. You might try posting what you get stuck on.


I am trying to write Java method but If this exists already then I can re-use it and save time.

The Java method is going to be specific to your solution not something you can just drop in for reuse.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic