• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Urgent - how to wirte dynamic query ?`

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am developing a web application where requriement is like there will be a startup servlet and it will take 3 request type
1) user information
2) location information
3) application information

Now within each reqquest there are around 8 parameters

e.g http://lookupservlet/userinfo?uid=1000&mla=true&location=loc1

so like this there can be parameters 1..8.

So i want to write SQL query such a way that if should get records for whtever parameter i pass say whether there are 2 parameters or 8 parameters.

Pls let me know how can acheive this?
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sejal,
You asked


Pls let me know how can acheive this?


That would depend on what database you are using. Oracle, for example, provides a feature called "native dynamic SQL".

Personally, I would probably write some stored procedure that takes (up to) eight parameters.

However, if you want it to be database independent, then I would put all the logic -- for building your query -- in your java code.

Good Luck,
Avi.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic