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 have two HOLD files that I need to join so I can get a many-to-many result. Instead, WF appears to join all the rows in Table2 with the first matching row in Table1, then I get the next row from Table1 (with the same key value) with no data from Table2.
JOIN LEFT_OUTER KEY IN TABLE1 TO ALL KEY IN TABLE2 END
A "flat" file join is actually a synchronized read of the two files. This gives them a behavior which is slightly different from "SQL" joins. I agree explore making both FOCUS files, and / or "MATCH FILE"
Of course you know if it was the end of the day. and you quickly created a report from the joined files, and rushed it off to "senior management", before going home. You would discover the next morning you had done a Cartesian product.
Jim Morrow Web Focus 7.6.10 under Windows 2003 MVS 7.3.3
We should be working with a reproducible example using one of the demo files.
Here's one. It first creates two FOCUS DB HOLD files, one that contains COUNTRY rows - 2 for each COUNTRY, and the second that contains 1 data column, CAR, for each COUNTRY. The output from joining them together contains the data column value for each of the COUNTRY rows:
SET HOLDLIST=PRINTONLY
TABLE FILE CAR
PRINT
COUNTRY NOPRINT
BY COUNTRY
ON TABLE HOLD AS H001 FORMAT FOCUS INDEX COUNTRY
MORE
FILE CAR
END
TABLE FILE CAR
SUM
CAR
BY COUNTRY
ON TABLE HOLD AS H002 FORMAT FOCUS INDEX COUNTRY
END
JOIN COUNTRY IN H001 TO ALL COUNTRY IN H002
TABLE FILE H001
PRINT
COUNTRY
CAR
ON TABLE SET STYLEMODE FIXED
END
File 1:
COUNTRY
-------
ENGLAND
ENGLAND
FRANCE
FRANCE
ITALY
ITALY
JAPAN
JAPAN
W GERMANY
W GERMANY
File 2:
COUNTRY CAR
------- ---
ENGLAND TRIUMPH
FRANCE PEUGEOT
ITALY MASERATI
JAPAN TOYOTA
W GERMANY BMW
Result:
COUNTRY CAR
------- ---
ENGLAND TRIUMPH
ENGLAND TRIUMPH
FRANCE PEUGEOT
FRANCE PEUGEOT
ITALY MASERATI
ITALY MASERATI
JAPAN TOYOTA
JAPAN TOYOTA
W GERMANY BMW
W GERMANY BMW
Please describe how your scenario is different from this one.This message has been edited. Last edited by: Francis Mariani,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Francis got it right when he specified to make th eintermediat hold FOCUS file rather than ALPHA's
It has to do with how FOCUS reads text files. As I understand it FOCUS can only make one pass through a text file and when it reaches the end, that is it.
I ran the following and got exactly the output you reported:
DEFINE FILE CAR
FACT1/A3 = DECODE COUNTRY (ENGLAND 'AAA' FRANCE 'AAA' ITALY 'BBB' JAPAN 'CCC');
END
TABLE FILE CAR
PRINT
FACT1
BY COUNTRY NOPRINT
WHERE COUNTRY NE 'W GERMANY'
ON TABLE HOLD AS STEP1
END
-RUN
JOIN CLEAR *
DEFINE FILE CAR
FACT2/A3 = 'AAA';
FACT3/A3 = DECODE COUNTRY (ENGLAND 'ABC' FRANCE 'DEF' ITALY 'GHI' );
END
TABLE FILE CAR
PRINT
FACT2
FACT3
BY COUNTRY NOPRINT
WHERE COUNTRY NE 'W GERMANY'
WHERE COUNTRY NE 'JAPAN'
ON TABLE HOLD AS STEP2
END
-RUN
JOIN CLEAR *
JOIN LEFT_OUTER FACT1 IN STEP1 TO MULTIPLE FACT2 IN STEP2 AS J0
TABLE FILE STEP1
PRINT
FACT1
FACT2
FACT3
END
-RUN
However changing the hold in step2 to:
ON TABLE HOLD AS STEP2 FORMAT FOCUS INDEX FACT2
and the result is exactly what you wanted.
Robert F. Bowley Jr. Owner TaRa Solutions, LLC
In WebFOCUS since 2001
Posts: 132 | Location: Gadsden, Al | Registered: July 22, 2005
I accidentally misrepresented my original case. Rather than a single field being joined, I actually have two fields.
JOIN Fld1 AND Fld2 IN HLD1 TO ALL FldX AND FldY IN HLD2
This apparently does NOT work. So I changed the program to build a concatenated key for each HOLD file (in FOCUS format) and join just the single field. AND IT WORKS!
Thanks to all who spent time helping me thru this!
And then it makes some more sense of course, since you can't do multi-field joins for focus files. That's a relational thing only. So by making it a single field join it works as expected.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007
Just to confuse everyone, you could also try a conditional join.
TABLE FILE VIDEOTRK
SUM LASTNAME
BY MOVIECODE
ON TABLE HOLD AS HOLD1
END
TABLE FILE MOVIES
SUM TITLE
BY RELDATE
ON TABLE HOLD AS HOLD2
END
JOIN FILE HOLD1 AT MOVIECODE TAG V1 TO ALL
FILE HOLD2 AT RELDATE TAG M1 AS JW1
WHERE V1.MOVIECODE EQ M1.MOVIECODE;
END
TABLE FILE HOLD1
PRINT LASTNAME
TITLE
END