From: | Keith Worthington <KeithW(at)NarrowPathInc(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Cc: | Derrick Betts <derrick(at)grifflink(dot)com> |
Subject: | Re: Search function |
Date: | 2005-06-23 12:03:19 |
Message-ID: | 42BAA507.8090807@NarrowPathInc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Davis | 2005-06-23 13:45:35 | Re: Search function |
Previous Message | Pradeepkumar, Pyatalo (IE10) | 2005-06-23 10:01:32 | Localization |