Focal Point
Where Clause

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3181009331

October 18, 2005, 02:33 PM
KarateExplosion
Where Clause
I have an input form that will allow the user to input different parameters. I want them to be able to enter only the ones they want and leave the others blank.

ex.

item_id = ________

color = __________

size = ___________

How would I set up the where clause in the fex to accept all of these paramters, but also leave any of them blank if the user only wants to narrow based on one or two of the parameters?
October 18, 2005, 02:41 PM
Francis Mariani
Here's one solution, I'm sure others will be posted.

-SET &comm_it = IF &item_id EQ '' THEN '-*' ELSE '';
-SET &comm_co = IF &color EQ '' THEN '-*' ELSE '';
-SET &comm_si = IF &size EQ '' THEN '-*' ELSE '';

&comm_it WHERE ITEM_ID EQ '&item_id';
&comm_co WHERE COLOR EQ '&color';
&comm_si WHERE SIZE EQ '&size';

The &comm_** parameters will have the comment tag (-*) if the input parameter is blank.
October 18, 2005, 02:45 PM
reFOCUSing
You will need to write some DM code for this.

It could look something like this:
-IF &ID EQ '' GOTO :NO_ID
WHERE ITEM_ID EQ &ID
:NO_ID

-IF &COLOR EQ '' GOTO :NO_COLOR
WHERE COLOR EQ &COLOR
:NO_COLOR

-IF &SIZE EQ '' GOTO :NO_SIZE
WHERE SIZE EQ &SIZE
:NO_SIZE
October 18, 2005, 03:39 PM
KarateExplosion
Francis,

If I do the code the way you recommended it works with one parameter. But when adding others it gives me an error saying '-*' is not recognized.

Here is the code I am using:

-SET &comm_GEO = IF &LOC EQ '' THEN '-*' ELSE '';
-SET &comm_SVC = IF &SVC EQ '' THEN '-*' ELSE '';
TABLE FILE Property
PRINT
Location
SVC_CD
INSTALLATION_CD
DESC
BY
Location
&comm_GEO WHERE Location EQ'&LOC'
&comm_SVC WHERE SVC_CD EQ'&SVC'

Any help is greatly appreciated.
October 18, 2005, 03:50 PM
Francis Mariani
It does work for me, but try adding .EVAL. See the example below:

-SET &ECHO=ALL;
-SET &COUNTRY = '';
-SET &SALES = '5000';
-SET &SEATS = '';

-SET &COMM_CO = IF &COUNTRY EQ '' THEN '-*' ELSE '';
-SET &COMM_SA = IF &SALES EQ '' THEN '-*' ELSE '';
-SET &COMM_SE = IF &SEATS EQ '' THEN '-*' ELSE '';

TABLE FILE CAR
SUM SALES
BY COUNTRY
BY MODEL

&COMM_CO.EVAL WHERE COUNTRY EQ '&COUNTRY';
&COMM_SA.EVAL WHERE SALES GE &SALES;
&COMM_SE.EVAL WHERE SEATS GE &SEATS;
END
October 18, 2005, 04:38 PM
KarateExplosion
Thanks Francis. adding .EVAL took care of the problem