• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic query generation  RSS feed

 
srinivasan kannan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have application,which is getting input from user,depends on the input,it whould generate querys from database(Stored procedure)database data dynamically.( we can use java also).
if any of you came across this situation,pls advise me to solve this situation..
Awaiting your valuable reply immediatly,
Srinivasan
 
Jose Ortuno
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srinivasan,
I had the opportunity to write a program whit almost the same approach.
My solution was try to keep the user interface simple because user don't have to know about SQL syntax.
So based in the database metadata I could determine information about database schema. For Instance fields, fields type, lenght an so on in order to popullate screen componets with the metadata.
Then my interface show a list with all fields in the database and a combo box whit all possible operators (ie. >, >=, <, etc)so the user could assemble a query by choosing just the field the operator a value (got from screen) a "conector" (and, or, beging, end contains etc. Afterwards I add the query being assembnled to a text area so the user can see the query before submit it.
The user repeated this steps until a button execute being pressed.
In program I just parse the information to a SQL sintax to perform the query.
I was told that called QUERY BY EXAMPLE.
Hope this help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!