When creating "Search" queries for our users, we've found that they prefer to break this up into components. We usually use a radio button control where they would select
1. Begins with, Contains, or Equals
2. Search in First Name, Last Name, Both
and a Text box control for the search string
Then we build the query using &vars that are passed.
As JG mentions, you have to be careful with case. We just convert to uppercase.
-SET &NAMSRCH=UPCASE(&NAMSRCH.LENGTH,&NAMSRCH,'A&NAMSRCH.LENGTH');
-SET &SNAM=IF &NAMSRCH GT ' ' THEN (&NAMSRCH || '%');
then we have the following WHERE section to decide how the query will work:
-IF &NAMSRCH EQ ' ' THEN GOTO SKIPNAMSRCH;
-IF &SEARCHTYPE NE 'Begins' GOTO SKIPBEGIN2;
WHERE (POL_NAM LIKE '&SNAM' );
-GOTO SKIPNAMSRCH
-SKIPBEGIN2
-IF &SEARCHTYPE NE 'Equals' GOTO SKIPEQUAL2;
WHERE (POL_NAM EQ '&NAMSRCH' );
-GOTO SKIPNAMSRCH
-SKIPEQUAL2
-IF &SEARCHTYPE NE 'Contains' GOTO SKIPNAMSRCH;
WHERE ( POL_NAM CONTAINS '&NAMSRCH' );
-SKIPNAMSRCH
(Our database is DB2)
Regards,
Darin
In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat