Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent - how to wirte dynamic query ?`

 
Hd Desai
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • 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?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic