Focal Point
[SOLVED] Variables inside Quotes

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7407086495

December 02, 2010, 03:43 PM
Joe Beydoun
[SOLVED] Variables inside Quotes
I'm trying to create this statement:

-SET &WHERE_DATE = IF &COMPARE EQ 'ON' THEN 'WHERE (DATE GE &STARTDATE AND DATE LE &ENDDATE) OR (DATE GE &STARTDATE2 AND DATE LE &ENDDATE2);' ELSE 'WHERE DATE GE &STARTDATE AND DATE LE &ENDDATE;';

However, with the single quotes, the varibles are being passed as literals and not replaced with the value sent from the procedure. I've toyed about with double-quote, some more singles, haven't figured it out yet.

Your help is appreciated.

This message has been edited. Last edited by: Joe Beydoun,


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
December 02, 2010, 04:00 PM
Waz
You need to use the variables as fields and concatenate them to the string.

-SET &WHERE_DATE = IF &COMPARE EQ 'ON' THEN 'WHERE (DATE GE ' | &STARTDATE | ' AND DATE LE ' | &ENDDATE 
- | ') OR (DATE GE ' | &STARTDATE2 | ' AND DATE LE ' | &ENDDATE2 | ');' ELSE 'WHERE DATE GE ' | &STARTDATE 
- | ' AND DATE LE ' | &ENDDATE | ';';


The other option is to add .EVAL to the variables, but that can be dangerous, as if thevariable has an embedded quote, the line may fail.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

December 02, 2010, 04:15 PM
Joe Beydoun
Thx for the response, I tried concatenation earlier and got this result from the parser:

-SET &WHERE_DTEI = IF ON EQ 'ON' THEN 'WHERE (ZHEDTEI GE ' | 20101201 | ' AND ZHEDTEI LE ' | 20101203 - | ') OR (ZHEDTEI GE ' | 20101206 | ' AND ZHEDTEI LE ' | 20101207 | ');' ELSE 'WHERE ZHEDTEI GE ' | 20101201 - | ' AND ZHEDTEI LE ' | 20101203 | ';';

(FOC260) AN OPERATION IS MISSING AN ARGUMENT


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
December 02, 2010, 04:21 PM
Joe Beydoun
The .EVAL worked great, I would like to heed your warnings though, but this particular scenario "should" never see embedded quotes.

so help with the concatenation syntax would be appreciated.


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
December 02, 2010, 04:35 PM
Waz
Is the -SET command on one line or three ?

The code I posted was on three lines.

The continuation character (first char) is a '-'.

In your post it is one line of code.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

December 02, 2010, 04:44 PM
Joe Beydoun
Ok, I feel like a little grasshopper, I didn't even know about continuation characters.

Works great, thanks Waz.


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
December 03, 2010, 02:54 AM
Dave
Joe,

me too... Roll Eyes

don't feel bad, I've been looking for this also, couldn't find it either.

And it's impossible to find in de help. If it's there at all. ( should be in language documentation I think. )

Thanks Waz.


_____________________
WF: 8.0.0.9 > going 8.2.0.5
December 03, 2010, 08:20 AM
Eswara Rao
-SET &STARTDATE = &YYMD;
-SET &ENDDATE = &YYMD+5;
-SET &STARTDATE2 = &YYMD+10;
-SET &ENDDATE2 = &ENDDATE+10;
-SET &COMPARE = ON;
-TYPE &STARTDATE
-TYPE &ENDDATE
-TYPE &STARTDATE2
-TYPE &ENDDATE2

-SET &WHERE_DATE = IF &COMPARE NE 'ON' THEN 'WHERE DATE GE ''&STARTDATE.EVAL'' AND DATE LE ''&ENDDATE.EVAL'';'
-ELSE 'WHERE (DATE GE ''&STARTDATE.EVAL'' AND DATE LE ''&ENDDATE.EVAL'') OR (DATE GE ''&STARTDATE2.EVAL'' AND DATE LE ''&ENDDATE2.EVAL'');';
-TYPE &WHERE_DATE
-EXIT


WebFOCUS 7.1
Windows
HTML, PDF,Excel