I use a CFA that builds a WHERE clause for exactly this situation. The
approximate format is:
SET VAR vmywhere TEXT = NULL
SET VAR vmyquery TEXT = 'SELECT <REST OF SELECT>' (NOTE: This is just the part
of the SELECT statement UPTO, BUT NOT INCLUDING the WHERE clause)
IF <CONDITION 1> IS NOT NULL THEN
SET VAR vmywhere = <CONDITION 1>
ENDIF
IF <CONDITION 2> IS NOT NULL THEN
IF vmywhere IS NULL THEN
SET VAR vmywhere = <CONDITION 2>
ELSE
SET vmywhere = .vmywhere & 'AND' & <CONDITION 2>
ENDIF
ENDIF
...
IF <CONDITION N> IS NOT NULL THEN
IF vmywhere IS NULL THEN
SET VAR vmywhere = <CONDITION N>
ELSE
SET vmywhere = .vmywhere & 'AND' & <CONDITION N>
ENDIF
ENDIF
IF vmywhere IS NOT NULL THEN
SET VAR vmyquery = .vmyquery & 'WHERE' & .vmywhere
ENDIF
&vmyquery
I check each condition in turn and add it to the WHERE clause if the condition
has been specified by the end user.
Thanks,
Jason
Jason Kramer
University Archives and Records Management
002 Pearson Hall
(302) 831 - 3127 (voice)
(302) 831 - 6903 (fax)
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dick Fey
Sent: Wednesday, June 19, 2013 12:03 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: How To... Suggestions ?
Probably didn't make this very clear.
Sometimes the search will include 2 of the options, others 3, 4, 5 or 6.
On 6/19/2013 10:51 AM, Dick Fey wrote:
> One of my people wants a form with the ability to search a table based
> on 6 different product specs.
> One to six specs may be entered to be searched, others will have no
> values entered.
>
> Question;
>
> How to build a query statement that searches based on an unknown
> number of values.
> This can't be as hard as I am envisioning.
>
>
> Dick Fey
> Carpet Broker Inc.
>
>
>
>