Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2002
    Posts
    21

    Unanswered: coverting conditional statements to sql

    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.
    Last edited by Sandro Psaila; 11-24-02 at 11:13.

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    What language are you writing the application in ?

  3. #3
    Join Date
    Nov 2002
    Posts
    21
    Originally posted by rnealejr
    What language are you writing the application in ?

    I am using JAVA....

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    What type of user input are you expecting ? - give some examples. What input from the user will the sql statements be based on ?

  5. #5
    Join Date
    Nov 2002
    Posts
    21
    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

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    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.

  7. #7
    Join Date
    Nov 2002
    Posts
    21
    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()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •