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?
Thanks!This message has been edited. Last edited by: Kerry,
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
July 08, 2009, 12:41 PM
BlueZone
The problem is with the missing quotes as Darin says. Here is one more solution -
------------------------------------------------------------------------------------------------- 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 !!
July 08, 2009, 02:23 PM
Glenda
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
July 08, 2009, 02:47 PM
susannah
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
July 08, 2009, 03:46 PM
Tomsweb
Thanks everyone for your wide array of replies. I never would of the approach used by Glenda:
-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.
July 08, 2009, 10:29 PM
susannah
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
July 09, 2009, 09:05 AM
PBrightwell
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
July 09, 2009, 10:07 PM
Doug
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'
July 10, 2009, 10:46 AM
j.gross
"&" 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
July 10, 2009, 06:25 PM
Doug
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.
July 10, 2009, 06:31 PM
Tom Flynn
AND,
If IBI ever tightens the code, a semi-colon is required with a WHERE statement, FYI...