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] where statement &variable

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] where statement &variable
 Login/Join
 
Master
posted
I am trying to create a dynamic WHERE COUNTRY EQ statement, and I am not getting quite the result I am looking for:

quote:

-*
-SET &PARAMETER = 'ENGLAND';
-*
-SET &ALPHA = 'WHERE';
-SET &BETA = 'COUNTRY';
-SET &COCO= 'EQ';
-SET &ZPARM = '''' || '&' | PARAMETER || '''';
-*
-SET &NOQTS = &ALPHA||' '|&BETA||' '|&COCO||' '|&PARAMETER||';';
-TYPE &NOQTS
-*EXIT
-*
TABLE FILE CAR
PRINT
CAR
MODEL
BODYTYPE
BY COUNTRY
&NOQTS
END
-RUN


Here is the error result:
quote:

TABLE FILE CAR
PRINT
CAR
MODEL
BODYTYPE
BY COUNTRY
WHERE COUNTRY EQ ENGLAND;
END
-RUN
0 ERROR AT OR NEAR LINE 20 IN PROCEDURE ADHOCRQ FOCEXEC *
(FOC258) FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: ENGLAND
BYPASSING TO END OF COMMAND
(FOC009) INCOMPLETE REQUEST STATEMENT


I need the WHERE statement to be:
WHERE COUNTRY EQ 'ENGLAND';

Can anyone help me? Frowner

Thanks!

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


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Virtuoso
posted Hide Post
Close! If you do a -SET &ECHO=ALL; at the beginning of your procedure and then run it, you would see the following for your &NOQTS line:

-SET &NOQTS = WHERE|' '|COUNTRY|' '|EQ|' '|ENGLAND|';';

which results in your where statement:

WHERE COUNTRY EQ ENGLAND;

Since there are no quotes around ENGLAND, WF thinks it is a field name. If you change your -SET to the following, you'll get what you need.

-SET &NOQTS = &ALPHA||' '|&BETA||' '|&COCO||' '|'''&PARAMETER.EVAL'''||';';

Note the .EVAL operator which is required to for immediate evaluation. Otherwise you get WHERE COUNTRY EQ '&PARAMETER';


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
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Platinum Member
posted Hide Post
The problem is with the missing quotes as Darin says. Here is one more solution -

  
-SET &QT = '''' ;

-SET &NOQTS = &ALPHA||' '|&BETA||' '|&COCO||' '| &QT || &PARAMETER|| &QT|| ';';


Sandeep Mamidenna


-------------------------------------------------------------------------------------------------
Blue Cross & Blue Shield of MS
WF.76-10 on (WS2003 + WebSphere) / EDA on z/OS + DB2 + MS-SQL
MRE, BID, Dev. Studio, Self-Service apps & a dash of fun !! Music
 
Posts: 218 | Location: Jackson, MS | Registered: October 31, 2006Report This Post
Guru
posted Hide Post
Here is another solution:

  
-*
-SET &PARAMETER = 'ENGLAND';
-*
-SET &ALPHA = 'WHERE';
-SET &BETA = 'COUNTRY';
-SET &COCO= 'EQ';
-SET &ZPARM = '''' || '&' | PARAMETER || '''';
-*
-SET &NOQTS = '&ALPHA.EVAL &BETA.EVAL &COCO.EVAL ''&PARAMETER.EVAL''';

-TYPE &NOQTS 
-*EXIT
-*
TABLE FILE CAR
PRINT 
CAR
MODEL
BODYTYPE
BY COUNTRY
&NOQTS.EVAL
END
-RUN





Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
Expert
posted Hide Post
cheat
use IF
APP PATH IBISAMP
TABLE FILE CAR
PRINT *
IF COUNTRY IS ENGLAND
END
.. so
-SET &MYCOUNTRY = 'ENGLAND';
TABLE FILE CAR PRINT *
IF COUNTRY IS &MYCOUNTRY
END
..
IF expects a constant, a value, eg a number or a character
The parm alone won't work with 'W GERMANY'
but you know that already
but with single value paramters, (numbers or codes), this is the easy way.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Master
posted Hide Post
Thanks everyone for your wide array of replies.
I never would of the approach used by Glenda:
quote:

-SET &NOQTS = '&ALPHA.EVAL &BETA.EVAL &COCO.EVAL ''&PARAMETER.EVAL''';

TABLE FILE CAR
PRINT
CAR
MODEL
BODYTYPE
BY COUNTRY
&NOQTS.EVAL
END
-RUN


Good One


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Report This Post
Expert
posted Hide Post
How about
-SET &ThisCountry = 'ENGLAND' ;
-SET &MyWhere = 'WHERE COUNTRY EQ ' | '''' || &ThisCountry || '''' ;
TABLE FILE CAR
PRINT CAR MODEL MPG
&MyWhere.EVAL
END
NOTE the use of the four single quotes.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
hmmm
Alpha Beta and Coco
weren't they the real names of the Supremes?




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Master
posted Hide Post
Why don't you do it the really easy way and just code:
-SET &PARAMETER = 'ENGLAND';
-SET &MYWHERE='WHERE COUNTRY EQ ''&PARAMETER'';';
TABLE FILE CAR
PRINT 
CAR
MODEL
BODYTYPE
BY COUNTRY
&MYWHERE.EVAL
END
  


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
I like that method as well. Less |'s. No need for the semi-colon. So how's this:
-SET &MYWHERE='WHERE COUNTRY EQ ''&PARAMETER''' ;
Which equates to
WHERE COUNTRY EQ 'ENGLAND'
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Virtuoso
posted Hide Post
"&" appearing within quotes in the left hand side of a -SET statement is treated literally. As it stands, that -SET treats &PARAMETER as a constant, not a reference (so you'd wind up fishing for "&PARAMETER", not "ENGLAND").

You need to append .EVAL to make it work.
-SET &MYWHERE= 'WHERE COUNTRY EQ ''&PARAMETER.EVAL'';' ;
...


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
Weird. But: Duh (on me). I knew that. I, sometimes, over use the ".EVAL" and forgot to include it here where it should be... But, it did work. The "WHERE COUNTRY EQ 'ENGLAND'" is the result of the "-SET &ECHO = ALL;"...Thanks Jack.
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report This Post
Expert
posted Hide Post
AND,

If IBI ever tightens the code, a semi-colon is required with a WHERE statement, FYI...

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Expert
posted Hide Post
Now, Tom, Why would they do a thing like that? LOL Wink
 
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] where statement &variable

Copyright © 1996-2020 Information Builders