Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Filtering in maitain
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Filtering in maitain
 Login/Join
 
Guru
posted
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,


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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, 2006Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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 7 - IE11.
in Focus since 1988
 
Posts: 1960 | Location: Netherlands | Registered: September 25, 2007Reply With QuoteReport This Post
Guru
posted Hide Post
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.

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Reply With QuoteReport This Post
Guru
posted Hide Post
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.

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Reply With QuoteReport This Post
Master
posted Hide Post
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: 931 | Location: At the Mast | Registered: May 17, 2007Reply With QuoteReport This Post
Master
posted Hide Post
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: 660 | Location: New York | Registered: May 08, 2003Reply With QuoteReport This Post
Guru
posted Hide Post
Thanks a lot Mark. It worked for me.

Warm Regards.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Filtering in maitain

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.