Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Recursive Java programming method for executing recursive SQL queries  RSS feed

 
Greenhorn
Posts: 3
  • 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.
 
author & internet detective
Marshal
Posts: 38504
653
Eclipse IDE Java VI Editor
  • 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
  • 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: 38504
653
Eclipse IDE Java VI Editor
  • 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
  • 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: 38504
653
Eclipse IDE Java VI Editor
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!