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.
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,
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, 2013
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
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
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?
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.
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?