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     [SOLVED] Compare value in one TABLE FILE against value in another Table File

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Compare value in one TABLE FILE against value in another Table File
 Login/Join
 
Platinum Member
posted
Hello,

I'm currently trying to look up a value in my second table file and compare it to another value in my first hold file. In the example below, I'm using the CAR file however this request is going through a ton of records. I am using WHERE DB_INFILE with a SQL script to narrow down the records and that's working great.

I want to try to find the most efficient way to compare "MPG" in the first table against "ACCEL" in the second table. I've been thinking DBLOOKUP might be a good command here but I haven't been able to get it to work. Is that more efficient then just doing a join? To get a sense of what I'm trying to do, I entered a field called "FLAG" which has the general logic I'd like to get working.

Does anyone have any ideas of what the best approach is here?

 TABLE FILE CAR
BY COUNTRY
BY LOWEST MPG
WHERE DEALER_COST LE 9000
ON TABLE HOLD AS 'TEST' FORMAT SQL_SCRIPT
END
?FF TEST

TABLE FILE CAR
SUM
	DEALER_COST
BY COUNTRY
BY ACCEL
BY TOTAL COMPUTE FLAG/A5 = IF TEST.MPG GE ACCEL THEN 'Y' ELSE 'N''
WHERE DB_INFILE(TEST, COUNTRY, COUNTRY)
END
?FF TEST2
-RUN
 


Thanks in advance!!

This message has been edited. Last edited by: Brandon Andrathy,


WebFOCUS 8204
 
Posts: 152 | Registered: July 10, 2018Report This Post
Virtuoso
posted Hide Post
There is probably no "good" answer to the question : most efficient way
I would say that the answer will strongly depend on type of data source and volume of data to proceed.

If you encounter a lack of performance, you will probably need to test several options and keep the one with best result.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Platinum Member
posted Hide Post
Hey Martin,

Thank you for your response. I got a join working how I’d like and performance is ok. Do you have an idea of other things could work here?

Would DB Lookup work? I tried doing that and got a server error. Assuming I’m doing something wrong. Is the below example correct or so I need to do something different?

 TABLE FILE CAR
BY COUNTRY
BY LOWEST MPG
WHERE DEALER_COST LE 9000
ON TABLE HOLD AS 'TEST' FORMAT SQL_SCRIPT
END
?FF TEST

TABLE FILE CAR
SUM
	DEALER_COST
BY COUNTRY
BY ACCEL
BY TOTAL COMPUTE FLAG/A5 = DB_LOOKUP(TEST, COUNTRY, COUNTRY, MPG);
WHERE DB_INFILE(TEST, COUNTRY, COUNTRY)
END
?FF TEST2
-RUN  


WebFOCUS 8204
 
Posts: 152 | Registered: July 10, 2018Report This Post
Guru
posted Hide Post
I'd prefer lookup instead of join in such cases because join can mess up data (null values with inner join or carthesian product with non unique key)

Here your example to lookup MPG:
 
TABLE FILE CAR
BY COUNTRY
BY LOWEST 1 MPG
WHERE DEALER_COST LE 9000
ON TABLE HOLD AS TEST FORMAT TAB
END

TABLE FILE CAR
SUM
	DEALER_COST
BY COUNTRY
BY ACCEL
BY TOTAL COMPUTE FLAG/D5 = DB_LOOKUP(TEST, COUNTRY, COUNTRY, MPG);
WHERE DB_INFILE(TEST, COUNTRY, COUNTRY)
END
?FF TEST2
-RUN   


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
 
Posts: 454 | Location: Europe | Registered: February 05, 2007Report This Post
Platinum Member
posted Hide Post
Hey Frans, thank you for your response. Do you have any idea why with DB_LOOKUP, causes the server to crash or for the report not to run?

Is it something with the type of data I am using?

The CAR example works great but then when I try to use it with an actual data source, I get an error.


WebFOCUS 8204
 
Posts: 152 | Registered: July 10, 2018Report This Post
Guru
posted Hide Post
Yeah in your example the flag had a decimal value (MPG) The result of the DB_LOOKUP needs to match the definition of the COMPUTE. I also added the 1 with lowest to make sure it's unique, however that should not matter for a DB_LOOKUP.

How big is the first table you are doing the lookup on? Is it a temporary table or do you lookup on a database table? And is it realy a crash, or do you see some kind of error code?


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
 
Posts: 454 | Location: Europe | Registered: February 05, 2007Report This Post
Member
posted Hide Post
How about using the MATCH command:

MATCH FILE CAR
SUM RETAIL_COST
BY COUNTRY
BY LOWEST MPG
WHERE...
RUN
FILE CAR
SUM DEALER_COST
BY COUNTRY
BY ACCEL AS MPG
WHERE...
AFTER MATCH HOLD OLD-OR-NEW
END
-RUN
TABLE FILE HOLD
PRINT *
WHERE...
END

It will automatically combine the two files using the BY fields and any that match will appear on the same line. OLD-OR-NEW will give you all of the results whether or not they match. OLD-AND-NEW will give you the intersection of the two files. There are the other variations like OLD is only the records in the first file and those that match from the second file. NEW is the opposite of OLD, etc, etc.


FOCUS 7.68, OpenVMS
WebFOCUS 7.7.03
 
Posts: 8 | Registered: February 15, 2010Report This Post
Platinum Member
posted Hide Post
Hey Frans, thank you very much for your response. When I try to do DB_LOOKUP with real data, I get "Request Terminated

"Reporting server request may have crashed, or was halted by the operator with a "hard kill"

Please investigate reporting server log."

Is this a known issue/something with an easy fix?


WebFOCUS 8204
 
Posts: 152 | Registered: July 10, 2018Report This Post
Platinum Member
posted Hide Post
I found out what my problem was. The format of the fields between the two tables wasn't the same. Additionally, DB_LOOKUP can't be converted to SQL apparently. I had my first file as a FORMAT SQL_SCRIPT.

Can anyone explain why DB_LOOKUP can't be converted to SQL?


WebFOCUS 8204
 
Posts: 152 | Registered: July 10, 2018Report This Post
Platinum Member
posted Hide Post
I was able to get this to work good enough for my purposes. Thanks all for the help!


WebFOCUS 8204
 
Posts: 152 | Registered: July 10, 2018Report 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     [SOLVED] Compare value in one TABLE FILE against value in another Table File

Copyright © 1996-2020 Information Builders