Focal Point
[SOLVED] help on the strrep

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

November 01, 2010, 02:44 PM
serenekk
[SOLVED] help on the strrep
hi, I am trying to replace the OR into , so that I can use it in the sql passthru.

What I have is this:
The string will look like this:
'AA' OR 'BB' OR 'CC';
and I want it to make this into
WHERE TESTVAL IN('AA','BB',CC');

-SET &OR=''' OR ''';

This is my strrep:
STRREP(&STR.LENGTH,(&STR),4,&OR,1,',',&STR.LENGTH,'A&STR.LENGTH') ;

what is it that I am missing? this does not work.

Thanks in advance!!

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


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
November 01, 2010, 02:51 PM
Francis Mariani
-SET &INVAR1 = '''AA'' OR ''BB'' OR ''CC''';

-* STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, outstring)

-SET &OUTVAR1 = STRREP (&INVAR1.LENGTH, &INVAR1, 4, ' OR ', 1, ',', &INVAR1.LENGTH, 'A&INVAR1.LENGTH');

-TYPE &INVAR1 - &OUTVAR1



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 01, 2010, 02:57 PM
dbeagan
-SET &STR = '''AA'' OR ''BB'' OR ''CC''';
-SET &ORSTR = STRREP(&STR.LENGTH,&STR,6,''' OR ''',3,''',''',&STR.LENGTH,'A&STR.LENGTH') ;
-TYPE ORSTR = &ORSTR


Also have to make special provision for single value without an OR.
If &STR is all numeric strrep will give an error.


WebFOCUS 8.2.06
November 01, 2010, 03:15 PM
j.gross
Your fourth argument, &OR, references its value 
      "' OR '"
whose length is 6 (two quotes, 2 spaces, 2 letters), 
not 4.

Either replace the six characters "' OR '" by the three characters "','" (and set the length arguments accordingly), as dbeagan 
suggests, or use
-SET &STR2 = STRREP(&STR.LENGTH,&STR, 4,' OR ', 3,',', &STR.LENGTH,'A&STR.LENGTH') ;
to replace 4 by 1

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
November 01, 2010, 03:24 PM
serenekk
Thank you very much! got it!


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment