Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] LIKE in WHERE with multiple values.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] LIKE in WHERE with multiple values.
 Login/Join
 
Silver Member
posted
Hi,

I have a textarea whose multiple property is Set to ON.A user can enter multiple zipcodes separated by commas.The requirement is I should bring all the records that has the zipcode that was entered in the textarea.

 TABLE FILE W_ADDR
PRINT *
WHERE ZIPCODE LIKE &ZIP;
END
-EXIT 


This worked for me.

Now there is a little change in the requirement where we should bring the records that start with the entered zipcodes.

for example if I enter 55116,55124 we should bring the records that has 55116,551161234,551164567,55124,551241234,551245678 values for the zipcode field.For this scenario my above code won't work.
I have to use '%' in the where clause.But my &ZIP has values separated by 'OR' how can I achieve this.Can somebody help me.
Thanks.

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.6.7
windows
Html,Pdf and Excel
 
Posts: 39 | Registered: September 03, 2010Report This Post
Expert
posted Hide Post
TABLE FILE W_ADDR 
PRINT * 
WHERE ZIPCODE LIKE &ZIP; 
END

I don't see how this works if you have multiple values separated by OR, you should be getting an error:
TABLE FILE CAR
PRINT
*
WHERE SEATS LIKE 3 OR 4 OR 5
END

Is ZIPCODE numeric or alpha?
What does &ZIP contain? Does entering 55116,55124 convert to '55116' OR '55124' or 55116 OR 55124?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Silver Member
posted Hide Post
The value for &ZIP is '55116' OR '55124'.
I have the Multiple property set for the Textarea.I think that is the reason i am getting each value separated by OR.

ZIPCODE is VARCHAR.
Entering 55116,55124 convert to '55116' OR '55124'.Thanks a lot for your time.This is important for me.


WebFOCUS 7.6.7
windows
Html,Pdf and Excel
 
Posts: 39 | Registered: September 03, 2010Report This Post
Platinum Member
posted Hide Post
Hi,

Just try changing the LIKE caluse to CONTAINS.
If the values are being passed as '55116' OR '55124' (i.e alphanumeric) to the fex from the launch page CONTAINS should work. You can avoid appending a % in this way.

thanks
Sashanka

This message has been edited. Last edited by: Severus.snape,


WF 7.7.03/Windows/HTML,PDF,EXL
POC/local Dev Studio 7.7.03 & 7.6.11
 
Posts: 103 | Registered: June 12, 2009Report This Post
Expert
posted Hide Post
The quickest way to solve this is to ask the user to enter the "%" wildcard when they want to select zipcodes starting with the entered values:

55116%,55124%

If that's not acceptable, then you'll have to parse the variable &ZIP and insert the % wildcard using Dialogue Manager.

Here's an example using the CAR file.

Var ZIP contains the passed values entered by the user.
Var ZIP1 strips the single quotes to make it easier for the next command.
Var Zip2 replaces the ' OR ' between each entered value with '% OR '. It also re-adds the single quotes. It also adds a single quote at the beginning and a %' at the end to complete the parsed string.

-SET &ECHO=ALL;

-SET &ZIP = '''CAN'' OR ''ENG'' OR ''ITA''';

-SET &ZIP1 = STRIP(&ZIP.LENGTH, &ZIP, '''', 'A&ZIP.LENGTH');

-SET &ZIP2 = '''' | STRREP (&ZIP1.LENGTH, &ZIP1, 4, ' OR ', 8, '%'' OR ''', 300, 'A300') || '%''';

-? &ZIP

TABLE FILE CAR
PRINT *
WHERE COUNTRY LIKE &ZIP2
HEADING
"&ZIP2"
END


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Silver Member
posted Hide Post
Thanks for your response.I completely forgot about CONTAINS.This is what exactly I need.Thanks again.


WebFOCUS 7.6.7
windows
Html,Pdf and Excel
 
Posts: 39 | Registered: September 03, 2010Report This Post
Expert
posted Hide Post
CONTAINS isn't the same as LIKE.

If they enter 55116,55124, one of the selected zip codes could be 11223355124, which may not be what you want.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Platinum Member
posted Hide Post
Yes I overlooked that possibility.
Method suggested by Francis is the best way of doing it.

thanks
Sashanka


WF 7.7.03/Windows/HTML,PDF,EXL
POC/local Dev Studio 7.7.03 & 7.6.11
 
Posts: 103 | Registered: June 12, 2009Report This Post
Silver Member
posted Hide Post
Thanks for correcting me Francis.

Coming to the code you posted
-SET &ZIP = '''CAN'' OR ''ENG'' OR ''ITA''';

where are all these quotes coming from.My &ZIP will contain values with single quotes.For ex : '55116' OR '55124'.
Could you explain that part.


WebFOCUS 7.6.7
windows
Html,Pdf and Excel
 
Posts: 39 | Registered: September 03, 2010Report This Post
Platinum Member
posted Hide Post
Hi,

Francis was only defaulting/setting the value for the variable &ZIP - when passed from the launch page you will see only '55116' OR '55124'.

thanks
Sashanka


WF 7.7.03/Windows/HTML,PDF,EXL
POC/local Dev Studio 7.7.03 & 7.6.11
 
Posts: 103 | Registered: June 12, 2009Report This Post
Expert
posted Hide Post
We can keep it simple with "IN". Consider the following:
-SET &RCOSTS = '8878, 13491, 5610' ;
TABLE FILE CAR
SUM  'CAR.BODY.RETAIL_COST'
     'CAR.BODY.DEALER_COST'
BY 'CAR.ORIGIN.COUNTRY'
BY 'CAR.COMP.CAR'
BY 'CAR.CARREC.MODEL'
WHERE RCOST IN (&RCOSTS)
END
Where "&RCOSTS" is your "&ZIP".Cool
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] LIKE in WHERE with multiple values.

Copyright © 1996-2020 Information Builders