hi all
I am building an application where the user enters a conditional statement and then i want to perform some action.
Eg
user input > if customer.name = sandro then send email
My program will read the user input and then constructs an sql statement to retrieve the required info... if the sql returns data then a separate method is invoked.
My problem is to transform this statement into the appropriate SQL...since this need to be constructed at run time and for any type of user input..
The language i am using is java, however i dont expect any code...I was only wondering if someone has any ideas of how this can be done..
Thank you in anticipation.What language are you writing the application in ?|||Originally posted by rnealejr
What language are you writing the application in ?
I am using JAVA...|||What type of user input are you expecting ? - give some examples. What input from the user will the sql statements be based on ?|||Originally posted by rnealejr
What type of user input are you expecting ? - give some examples. What input from the user will the sql statements be based on ?
The users are expected to choose from a form which will display the available table attributes and the conjunctives AND OR and NOT.
eg of the typical input
If customer.name = "sandro" and department.name = "maintence" then send email.
what i need to do is to dynamically generate an sql that extracts the required info (based on the user input)......... if the dataset returned from the generated query contains data then this implies that the conditional part succeeds... and in turn i can invoke a method which sends the email...
Hope this is clear.........
Thank you for your interest
Sandro|||After the user makes the selections just do an executeQuery within java with the string that you create. So you might separate the sql statement into a select, from, where ... strings and combine these and pass to the executeQuery using the parameter selection by the user. By separating the parts of the sql statement you can create reusable components. Do you need to know the contents of the returned result set or just that something exists ? If it is the latter, just do a select count(*) to validate. I am a little unclear as to what your problem is, so I hope this answers your question.|||Originally posted by rnealejr
After the user makes the selections just do an executeQuery within java with the string that you create. So you might separate the sql statement into a select, from, where ... strings and combine these and pass to the executeQuery using the parameter selection by the user. By separating the parts of the sql statement you can create reusable components. Do you need to know the contents of the returned result set or just that something exists ? If it is the latter, just do a select count(*) to validate. I am a little unclear as to what your problem is, so I hope this answers your question.
Thank you very much for your advice...... it s pretty much similar to what i had in mind...
By any chance do u know how i can calculate the genereted query computational complexity? i.e. its order O()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment