Re: Search function
От | Keith Worthington |
---|---|
Тема | Re: Search function |
Дата | |
Msg-id | 42BAA507.8090807@NarrowPathInc.com обсуждение исходный текст |
Ответ на | Re: Search function ("Derrick Betts" <derrick@grifflink.com>) |
Список | pgsql-novice |
>> Hi All, >> >> I am working on an application that has a search dialog. The dialog >> is automatically populated with all of the available fields. It gets >> the field names from the views that were used on the form that the >> search dialog was launched from. >> >> The issue that is slowly getting unmanageable is handling the >> different data types. If it is a date do this, if it is a string do >> that and if it is a boolean do something else. >> >> I would like to remove this complexity from the application. >> >> I am hoping that there is a way given the view/column names that I can >> either >> 1) dynamically build the WHERE clause >> 2) dynamically build the whole query >> 3) dynamically build the whole query, run it and return the results >> >> Has anyone tried something like this before? >> >> -- >> Kind Regards, >> Keith > > I have built search functions for web pages that build the SQL string > dynamically and return the result from a function through a result set. > For example, your form may have three input fields with several > "options" the user can search with: Date_To: (an input field) Date > From: (an input field) Destination: (a drop down list with airport codes). > > Your SQL would look like: "SELECT * FROM table WHERE date1 >= > Date_To_variable_from_the_form AND date2 <= > Date_From_variable_from_the_form AND destination = > Destination_from_the_form. > > You would then execute the statement and return the results to your > application. > > Is this what you were looking for? > > Derrick Derrick, I am trying to create something more dynamic. At the moment the user has a drop down list that is populated based on the view a form uses. There is a second drop down list that contains the operators (=, <, >, >=, <=, <>, LIKE). There is also a text box where the user can enter the desired data. Finally the user has the option of selecting AND, OR or NONE and specifying a second condition. The challenge is that if a user selects name = tom the code is different then if the user selects closed = true -- Kind Regards, Keith
В списке pgsql-novice по дате отправления: