Subject | Re: Is there a parameter value of 'don't care' ? |
---|---|
Author | Scott Moon |
Post date | 2007-01-11T19:05:57Z |
Can you just build the WHERE clause dynamically from the app based on
the user's inputs? Something like this:
string WhereClause = '';
if :Co_Name <> '' then
WhereClause = 'WHERE Co_Name like' & :Co_Name;
end if;
if :Town <> '' then
if WhereClause <> '' then
WhereClause = WhereClause & ' and ';
else
WhereClause = 'WHERE ';
end if;
WhereClause = WhereClause & 'Town like ' & :Town;
end if;
and so on. Using "like" in the dynamically built clause will also
allow the use of wildcards.
HTH
Scott Moon
--- In firebird-support@yahoogroups.com, "tickerboo2002" <egroup@...>
wrote:
the user's inputs? Something like this:
string WhereClause = '';
if :Co_Name <> '' then
WhereClause = 'WHERE Co_Name like' & :Co_Name;
end if;
if :Town <> '' then
if WhereClause <> '' then
WhereClause = WhereClause & ' and ';
else
WhereClause = 'WHERE ';
end if;
WhereClause = WhereClause & 'Town like ' & :Town;
end if;
and so on. Using "like" in the dynamically built clause will also
allow the use of wildcards.
HTH
Scott Moon
--- In firebird-support@yahoogroups.com, "tickerboo2002" <egroup@...>
wrote:
>
> Users of my app will be able to fill in parameters that go into a
> query to search for rows. The query has fixed parameters in the where
> clause: i.e.
>
> where
> Co_name=:Co_Name and
> town=:town and
> Num_Employees=:Num_Employees
> etc
>
> Let's say the user is not interested in Num_Employees, is it possilble
> to set the parameter so that clause is ignored?
>
> I assume for varchar entries I can just set Col=* (or is it %?)
>
> Thanks
>
> David
>