Focal Point
[SOLVED] How to add single quotes around a value

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

November 22, 2014, 12:41 AM
info4pal
[SOLVED] How to add single quotes around a value
Hi,

I have a textbox and Iam entering multiple Id's separated by commas(say abcd,xyz1,pqrs) and while passing to the fex file I need the single quotes to be around the ID's(say something like select * from table where ID in ('abcd','xyz1','pqrs')...

Could anyone please help me on how to do this.

Thanks a lot in advance!

Regards,
Apoorva

This message has been edited. Last edited by: <Kathryn Henning>,
November 22, 2014, 05:40 AM
Twanette
Hi,
Perhaps you can use the STRREP function?
Concatenate a single quote to the beginning and end, then replace the comma with quote-comma-quote.

STRREP: Replacing Character Strings
The STRREP replaces all instances of a specified string within a source string. It also supports replacement by null strings.

Syntax: How to Replace Character Strings
STRREP (inlength, instring, searchlength, searchstring, replength,
repstring, outlength, output)



WebFOCUS 8.2.06 mostly Windows Server
November 23, 2014, 05:56 AM
SSander
Hi,
STRREP is fucntion that solves most cases. But it also has it own limitations.

Check this thread, there is very nice solution for it:
http://forums.informationbuild...411028331#2411028331


Release: WebFOCUS 8104, AppStudio: 8105
OS: Windows
Output: HTML,Excel,Active Reports
November 23, 2014, 09:01 AM
HarryLo
Try this

''''|'value'|''''

that's 4 single quotes


WebFOCUS 7.6
Windows, All Outputs
November 24, 2014, 06:46 AM
info4pal
Hi,

Thanks to all of you for your inputs...Would you mind posting a sample solution for this below CAR file :

-DEFAULT &COUNTRY=ENGLAND,ITALY;



TABLE FILE CAR

PRINT *

WHERE COUNTRY IN (&COUNTRY)

END

-RUN


Thanks a lot in advance!

Regards!
November 24, 2014, 08:08 AM
Alan B
Twanette is correct.
-DEFAULT &COUNTRY= 'ENGLAND,ITALY'

-SET &COUNTRY = TRUNCATE(&COUNTRY);

-SET &COUNTRY = '''' || STRREP (&COUNTRY.LENGTH,&COUNTRY,1,',',3,''',''',1000,'A1000') || '''';

-SET &COUNTRY = TRUNCATE(&COUNTRY);

The DEFAULT has to have quotes around and no semi-colon at the end, as the comma splits the value and the semi-colon is not required. The first TRUNCATE may be useful when value comes from an HTML form. The 1000/A1000 length can be any value that would work with your process.


Alan.
WF 7.705/8.007
November 24, 2014, 08:40 AM
info4pal
Hi,

Thanks a lot Alan and everyone for your help.
It worked!

Regards
November 24, 2014, 09:18 AM
stur0063
Here's a little explanation of the 4 ticks:

One tick starts the string literal.
Two ticks escapes it - implying you want to print a single tick - as opposed to ending the string.
The very last tick closes the string literal.


webFOCUS 8207.15
WindowsServer 2019
November 28, 2014, 08:12 AM
info4pal
Hi,

Thanks a lot everyone for the help.
It worked!!

Regards!