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.
Hi, I have comma separated values in a variable.I want to use it in WHERE clause to filter records against a column in databse table as we do it using IN operator in Oracle. As we do not have IN in maintain, How can we achieve this requirement. E.g. Suppose variable contains value 'A,AB,ABC' . Now I have to use these values in WHERE clause as
WHERE [coumn name] eq 'A' and [coumn name] eq 'AB' and [coumn name] eq 'ABC';
There can be any number of values in variable. Please suggest a way to achive this in maintain.
Thanks in advance.This message has been edited. Last edited by: Kerry,
I am not a SQL specialist, but I wonder if this where clause would work. The column name can not be A and B and AB at the same time. I would suggest to change the AND into OR
Frank
prod: WF 7.6.10 platform Windows, databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7 test: WF 7.6.10 on the same platform and databases,IE7
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006
1. get it to work in TABLE first, not Maintain. 2. when it works call tha table fex from the maintain giving it the parameter list and catching the result in a stack. Be sure the stack contains at least the exact fields table will return. Done!
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
Hi Frank, Yes you are right. My mistake. But can you please tell me the way to convert the comma separated string into WHERE clause string. That will really help.
Hi GamP, In my case it would require lot of code restructuring and that would be very costly affair for me as this is just a minor enhancement in an existing application. Is there any way to handle it in maintain easily as i have to deliver it urgently and i can't take more time for this.Please help.
GamP's suggestion is the right way to go and it's not terribly difficult to write.
1. Write a traditional FOCUS routine that performs your select.
TABLE FILE X PRINT A B C WHERE C IN (&1); ON TABLE PCHOLD END
That &1 is your list of values, your string 'A','AB','ABC'. It will be the variable you call the routing with. Let's call this routing select_records.fex.
2. Exchange your Maintain select for the call to the routine.
-* for all next x.a into StkRecords where x.c EQ 'a'; infer x.a into StkRecords; EXEC select_records from string_of_values into StkRecords;
3. At this point you have StkRecords filled with your values. The amper variables in your Focexec are positional -- that is the first one sent is &1, the second &2 and so on. So string_of_values arrives in &1. Your INTO stack receives the results of the select.
It's just that simple, and using FOCUS routines for your selections opens up your Maintain code to all the power of a focexec. Joins, hold files, the works. Seriously, this is the fastest, easiest way to do this. You could put together a loop in Maintain and select the values one at a time, but that's much more work than what GamP put you onto in his first post.
J.
Posts: 1012 | Location: At the Mast | Registered: May 17, 2007
Here is the Maintain solution. Perform a loop and use MNTGETTOK to get the value before the comma each time through the loop. Then use the value in a NEXT with WHERE statement to add the values from the database into the stack.
MAINTAIN FILE MOVIES MODULE IMPORT(MNTUWS) COMPUTE STRING/A0 = "ROOF,WIND,TOP"; COMPUTE I/I3=1; REPEAT WHILE VAL NE '' COMPUTE VAL/A0=MNTGETTOK(STRING,",",I); REPOSITION MOVIECODE FOR ALL NEXT MOVIECODE TITLE INTO STK(STK.FOCCOUNT+1) WHERE TITLE CONTAINS TRIM(VAL) COMPUTE I=I+1; ENDREPEAT END
Mark
Posts: 663 | Location: New York | Registered: May 08, 2003