Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Variable listing values for use in multiple WHEREs
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Variable listing values for use in multiple WHEREs
 Login/Join
 
Member
posted
Is it possible to use a variable for a list for use in several WHEREs throughout a fex? If so, can somebody help me out with syntax?

Using "WHERE field IN ('value1','value2',...)" works, but if my fex needs to apply this WHERE to 4 tables, changing the values requires changing them in each WHERE line.

Using a FILEDEF with "WHERE field IN file" works also, but having to update/upload a file every time I want to change values is overkill and cumbersome.

Seems to me that it should be possible to define a variable at the top of the fex with whatever values, then just stick that variable in as many WHEREs as I need. But I can't get this to work and I'm not finding any answers in the help docs or existing forum posts.

-* =====A. This works=====
TABLE FILE CAR
SUM CNT.MODEL
BY COUNTRY
WHERE COUNTRY IN ('JAPAN','ITALY');
END
-*
TABLE FILE OTHERTBL
SUM CNT.FOO
BY COUNTRY
WHERE COUNTRY IN ('JAPAN','ITALY');
END

-* =====B. This works=====
FILEDEF CTRYLIST DISK Z:/WHATEVER/CTRYFILE.TXT
TABLE FILE CAR
SUM CNT.MODEL
BY COUNTRY
WHERE COUNTRY IN FILE CTRYLIST;
END
-*
TABLE FILE OTHERTBL
SUM CNT.FOO
BY COUNTRY
WHERE COUNTRY IN FILE CTRYLIST;
END

-* =====C. I want something like this but I can't get it to work=====
-SET &CTRYLIST=('JAPAN','ITALY');
TABLE FILE CAR
SUM CNT.MODEL
WHERE COUNTRY IN &CTRYLIST;
END
-*
TABLE FILE OTHERTBL
SUM CNT.FOO
WHERE COUNTRY IN &CTRYLIST;
END

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


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 2 | Registered: November 23, 2010Reply With QuoteReport This Post
Expert
posted Hide Post
When providing values to Dialogue Manager variables that contain quotes, you need to include more quotes:

-SET &ECHO=ALL;

-SET &CTRYLIST = '(''JAPAN'',''ITALY'')';

TABLE FILE CAR
SUM CNT.MODEL
WHERE COUNTRY IN &CTRYLIST;
END

TABLE FILE OTHERTBL
SUM CNT.FOO
WHERE COUNTRY IN &CTRYLIST;
END
I'm not sure what the term for this is or where it's documented. You may be able to play with QUOTEDSTRING, but my suggestion is the easiest.


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, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
-SET assigns a literal value, or a value that is computed in an arithmetic or logical expression, to a variable.

Single quotation marks around a literal value are optional unless it contains an embedded blank, comma, or equal sign, in which case you must include them.

The syntax is:

-SET &[&]name= {expression|value};

where:

&name - Is the name of a variable whose value will be set.

expression - Is a valid expression. Expressions can occupy several lines, so end the command with a semicolon.

value - Is a literal value assigned to the variable. If the literal value contains commas or embedded blanks, you must enclose the value in single quotation marks. If the value contains a single quote, place two single quotes where you want one to appear.


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, 2005Reply With QuoteReport This Post
Member
posted Hide Post
Thank you! I put in more quotes like you said and it works now!


WebFOCUS 7.6
Windows, All Outputs
 
Posts: 2 | Registered: November 23, 2010Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Variable listing values for use in multiple WHEREs

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.