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] Variable with multiple values

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Variable with multiple values
 Login/Join
 
Member
posted
I need an array or set-like variable to check membership of values. This seems simple enough but I have not found this information in the documentation, on forums and through web searches.

Example:

Instead of
WHERE MYTABLE.COUNTRY IN ('AU', 'NZ', 'TH', 'ZA');


I want to set up something re-usable like
-SET &COUNTRIES = ('AU', 'NZ', 'TH', 'ZA');


to use as
WHERE MYTABLE.COUNTRY IN &COUNTRIES;


I have tried various other approaches, including concatenated strings, without success.

How can this be done in WebFocus?

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 7.7.03
Windows 7 64-bit
 
Posts: 17 | Registered: February 23, 2016Report This Post
Virtuoso
posted Hide Post
I'm not sure why you have to put this in a variable. Why not just do this:

 
TABLE FILE CAR
SUM SALES BY CAR
WHERE COUNTRY EQ 'ENGLAND' OR 'FRANCE';
END
 


If you're manufacturing the variable on the fly, try concatenating the values using ' OR '


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
-*
-SET &COUNTRIES = '(''ENGLAND'',''ITALY'')';
-*
TABLE FILE CAR
PRINT CAR
BY COUNTRY
WHERE COUNTRY IN &COUNTRIES
END


WebFocus 8.201M, Windows, App Studio
 
Posts: 227 | Location: Lincoln Nebraska | Registered: August 12, 2008Report This Post
Virtuoso
posted Hide Post
The issue is with the quotes. So doing it manually car be a pain.
The below do work
-SET &COUNTRIES = '(''ENGLAND'', ''FRANCE'', ''ITALY'')';
TABLE FILE CAR
SUM SALES
BY COUNTRY
BY CAR
WHERE COUNTRY IN &COUNTRIES;
END


But how does &COUNTRIES is normally provided ? Is it coming from a selection made from a control in a HTML page ?


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Platinum Member
posted Hide Post
More than likely the last two posts will solve your issue, but you said you haven't had any success. With how you have it currently are you getting an error? Just curious on the details surrounding the issue.


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7
 
Posts: 146 | Registered: November 09, 2015Report This Post
Master
posted Hide Post
We used to use IN() a lot.
Turns out that doesn't really work well with HTML parameters.
OR works better.

-SET &ARRAY = ' ''AU'' OR ''NZ'' OR ''TH'' OR ''ZA'' ';

TABLE FILE x
WHERE COUNTRYCODE EQ &ARRAY
END


is the easy way.


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 668 | Location: Veghel, The Netherlands | Registered: February 16, 2010Report This Post
Member
posted Hide Post
Thanks for all your answers. Both jfr99's/MartinY's and Dave's methods are working for me.

I should probably look more into how WebFocus treats quotes.

@MartinY/Dave - no HTML parameters involved, the list will be hardcoded.

@BabakNYC - the reason I want to use a variable is that my list of countries is actually much longer, used in several places and it may need updating from time to time. A variable will keep the code shorter and easier to maintain.

@jcannavo - the only error message I got with the original, incorrect syntax was "EDA no data".

Thanks again!


WebFOCUS 7.7.03
Windows 7 64-bit
 
Posts: 17 | Registered: February 23, 2016Report This Post
Platinum Member
posted Hide Post
You can also put your values in a file and then use ...

WHERE COUNTRY IN FILE HLD_CNTRY
or
WHERE NOT COUNTRY IN FILE HLD_CNTRY

Here's an example ...

TABLE FILE CAR
SUM COUNTRY
BY COUNTRY NOPRINT
WHERE COUNTRY IN ('ENGLAND','ITALY')
ON TABLE SET PRINTONLY ON
ON TABLE HOLD AS HLD_CNTRY
END
-*
TABLE FILE HLD_CNTRY
HEADING
" VALUES IN HLD_CNTRY "
" "
PRINT *
END
-*
TABLE FILE CAR
HEADING
" WHERE COUNTRY IN FILE HLD_CNTRY "
" "
PRINT CAR
BY COUNTRY
WHERE COUNTRY IN FILE HLD_CNTRY
END
-*
TABLE FILE CAR
HEADING
" WHERE NOT COUNTRY IN FILE HLD_CNTRY "
" "
PRINT CAR
BY COUNTRY
WHERE NOT COUNTRY IN FILE HLD_CNTRY
END


WebFocus 8.201M, Windows, App Studio
 
Posts: 227 | Location: Lincoln Nebraska | Registered: August 12, 2008Report 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] Variable with multiple values

Copyright © 1996-2020 Information Builders