Focal Point
[SOLVED] passing multiple values from textarea to sql

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

July 22, 2015, 02:35 PM
Suzy
[SOLVED] passing multiple values from textarea to sql
In my code I've already parsed the values from the textarea with javascript from the search page. I'm trying to pass those values to the SQL, but it's only picking up the first value.

 
-DEFAULT &ITEM_LIST = 'ENGLAND','FRANCE','ITALY';

TABLE FILE CAR
SUM
   DEALER_COST
   RETAIL_COST
BY COUNTRY
BY CAR
WHERE COUNTRY IN ('&ITEM_LIST');
END


Generated SQL is: WHERE COUNTRY IN ('ENGLAND')

How do I get it to read the rest of the values?

This message has been edited. Last edited by: <Kathryn Henning>,


WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV
July 22, 2015, 02:43 PM
jfr99
Hi Suzy

Try this ...

-DEFAULT &ITEM_LIST = '''ENGLAND'',''FRANCE'',''ITALY''';


WebFocus 8.201M, Windows, App Studio
July 22, 2015, 02:48 PM
jfr99
And then this ...

TABLE FILE CAR
SUM
DEALER_COST
RETAIL_COST
BY COUNTRY
BY CAR
WHERE COUNTRY IN (&ITEM_LIST);
END


WebFocus 8.201M, Windows, App Studio
July 22, 2015, 03:31 PM
Suzy
Is there a function to add the extra quotes to the &ITEM_LIST


WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV
July 22, 2015, 06:04 PM
Waz
Depends on where you wants the quotes.

You can use &ITEM_LIST.QUOTEDSTRING. But this puts single quotes around the whole string.


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!

July 22, 2015, 06:57 PM
Suzy
I removed the single quotes coming from the search page. To pass the items as 'ITEM1,ITEM2,ITEM3'. Then I used STRREP function.

-SET &MIDLISTLENGTH = &MID_LIST.LENGTH + 4;
-SET &MIDLIST=STRREP(&MID_LIST.LENGTH, '&MID_LIST.EVAL', 1, ',', 5, ''',''', &MIDLISTLENGTH.EVAL, 'A&MIDLISTLENGTH.EVAL');

WHERE MID IN ('&MIDLIST')
  



WebFOCUS 8.0.08
Solaris
HTML, PDF, XLS, CSV