Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Building A Where Clause from a User Submitted CSV List (Looping)

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Building A Where Clause from a User Submitted CSV List (Looping)
 Login/Join
 
Member
posted
I've search the WebFocus forum for something like this, and I've found a couple of posts that seem to do what I want, but I can't quite figure them out. I was hoping somebody could help me with this.

I've got a web form that allows user to enter a comma seperated value list. A possible input would be:

"BKTA-%,XGEM%,DT2-PMX-%,XSWWTW2%"

What I'd like to do is generate a where clause like this:

WHERE FIELD LIKE 'BKTA-%' OR FIELD LIKE 'XGEM%' OR FIELD LIKE 'DT2-PMX-%' OR FIELD LIKE 'XSWWTW2%'

Any idea how I can do that? I would assume I'd need to use GETTOK, but my skills with webfocus are not very good. Any hints would be appreciated.
 
Posts: 19 | Registered: October 24, 2006Report This Post
Virtuoso
posted Hide Post
Chris

GETTOK is correct, try this
  
-SET &incoming = 'BKTA-%,XGEM%,DT2-PMX-%,XSWWTW2%';
-SET &screen =' ';

-SET &CNTR = 0;

-:MYLOOP
-SET &CNTR=&CNTR+1;

-SET &var = GETTOK(&incoming,&incoming.LENGTH,&CNTR,',', 12, 'A12');
-IF &var EQ ' ' GOTO :OUT_LOOP;
-SET &var2 = ' ' | '''' || &var || '''' ;

-SET &screen = IF &CNTR EQ 1 THEN 
- 'WHERE FIELD LIKE ' |  &var2 ELSE
- &screen || ' OR FIELD LIKE ' ||  &var2 ;
-GOTO :MYLOOP
-:OUT_LOOP
-TYPE &screen




Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Expert
posted Hide Post
quote:
WHERE FIELD LIKE 'BKTA-%' OR FIELD LIKE 'XGEM%' OR FIELD LIKE 'DT2-PMX-%' OR FIELD LIKE 'XSWWTW2%'

Chris, you can shorten this phrase to
WHERE field LIKE 'BKTA-%' OR 'XGEM%' OR 'DT2-PMX-%' OR 'XSWWTW2%'




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
Chris,
There is a function called STRREP which is used to replace strings. So you could code something like this:
-SET &INSTR='BKTA-%,XGEM%,DT2-PMX-%,XSWWTW2%';
-SET &INSTRLEN=&INSTR.LENGTH;
-SET &OR=''' OR ''';
-SET &WHERE=STRREP(&INSTRLEN, &INSTR, 1, ',', 6, &OR, 200, 'A200');
(I use an output length of 200 for good measure)
Now all the commas have been replaced by ' OR '.
Your WHERE statement will then be:
WHERE FIELD LIKE '&WHERE'
Don't forget the quotes around &WHERE.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Virtuoso
posted Hide Post
Danny

If you use FOCUS datasource, (never used this on other data source), and the LIKE operator, you have to close the final quote in the string up to within the length of the field, after the STRREP add:

-SET &WHERE = '''' || &WHERE || '''';

and use:

WHERE FIELD LIKE &WHERE ;

otherwise the last screening option may fail.

It works okay if you use EQ instead of LIKE.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Virtuoso
posted Hide Post
Alan,
True. I forgot about the trailing blanks.
You could calculate the length of the &WHERE string but your -SET does the trick better.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report This Post
Member
posted Hide Post
Alan B,

I tried your suggestion, but I think it kept getting caught in an endless loop.

Danny-SRL,

Thank you sir, for making me look like a fool in front of the entire internet Wink . I was so wrapped up in trying to loop through the structure, that it never occurred to me that all I needed to do was replace the commas with "OR"s.

In fact, I didn't even need to do in WebFocus at all. I treated the string in JavaScript before I sent it to WebFocus for execution.

Thanks for the suggestions! I got the report working now, as I want.

Chris
 
Posts: 19 | Registered: October 24, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Building A Where Clause from a User Submitted CSV List (Looping)

Copyright © 1996-2020 Information Builders