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] Problem with a specific merging

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Problem with a specific merging
 Login/Join
 
Silver Member
posted
Hello everybody,
I will explain the problem shortly :

I have to perform a specific type of merging two tables - e.g. lets say for example we have the following tables:

TABLE1 TABLE2
------ -------

COLUMN_1 COLUMN_2
------------- -------------
RECORD_1 (*) RECORD_1 (*)
RECORD_1 (**) RECORD_1 (**)
RECORD_2 (*) RECORD_1 (***)
RECORD_2 (**) RECORD_2 (*)
RECORD_2 (***) RECORD_2 (**)
RECORD_4 (*) RECORD_3 (*)

So what I am trying to do is to merge the two tables ( lets say the TABLE1 is the master and TABLE2 is the detail ) so that only the first unique record in TABLE1 is matched ot all similar records in TABLE2 and the other records ( together with all other unmatched in TABLE1 and TABLE2 ) are printed as well. In the example given ( the '*' only indicates what of the same records must be matched ) the result should be something like :

MATCHED_TABLE:

COLUMN_1 COLUMN_2
-------- -----------

RECORD_1 (*) RECORD_1 (*)
RECORD_1 (*) RECORD_1 (**)
RECORD_1 (*) RECORD_1 (***)
RECORD_1 (**) ___________ - unmatched in master
RECORD_2 (*) RECORD_2 (*)
RECORD_2 (*) RECORD_2 (**)
RECORD_2 (**) ___________ - unmatched in master
RECORD_2 (***) ___________ - unmatched in master
RECORD_4 (*) ___________ -unmatched in master
___________ RECORD_3 (*)-unmatched in detail

I've tried using a combination of the join and match command but only with a close similarity to the result expected.
Any suggestions to the problem would be very appreciated.
Thanks in advance.

This message has been edited. Last edited by: Kerry,


WF 7.6.5 / OS: XP / FOCUS
 
Posts: 42 | Registered: September 01, 2008Report This Post
Virtuoso
posted Hide Post
Try this:
 
MATCH FILE MFD1
SUM COL1
BY COL1 AS JOINFLD
RUN
      FILE MFD2
SUM COL2
BY COL2 AS JOINFLD
AFTER MATCH HOLD OLD-OR-NEW
END

TABLE FILE HOLD
PRINT COL1 AS 'IN FILE 1'
      COL2 AS 'IN FILE 2'
BY JOINFLD
END
 

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
Use MATCH and try SUM FST.fieldname BY record from the first table followed by PRINT fieldnames BY record from the second table.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
I don't think MATCH will work. MATCH won't pick up the 3 records for RECORD2 that match the first record for RECORD1.

I would think a join with a SET ALL=ON makes more sense.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Silver Member
posted Hide Post
Thanks very much for the replies - MATCH that uses SUM with FST. and then PRINT for the second table is a close decision but another problem occurs - the similar records in the master are not printed.

( RECORD_1 (**) ___________ - unmatched in master
RECORD_2 (**) ___________ - unmatched in master
RECORD_2 (***) ___________ - unmatched in master )

so if there is some way to include them would be great.
I suppose using MORE after taking the similar records in the master table and adding empty columns would solve fully the problem but I was wondering if it could be done only with a MATCH block.

Ginny: I thought about that but a JOIN TO ALL would join the similar records in the master to all the corresponding records in the detail. And maybe that way a decision could arise but it won't be short either way.


WF 7.6.5 / OS: XP / FOCUS
 
Posts: 42 | Registered: September 01, 2008Report This Post
Expert
posted Hide Post
Sounds like a McGyver case if the fields you want are the main ones.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Silver Member
posted Hide Post
What you have advised me + filtering and MORE does the job.


e.g. for the example j.gross gave :
MATCH FILE FILE1
  SUM FST.DATA1 ...
  BY KEY1 AS KEY
RUN
FILE FILE2
  PRINT DATA2 ...
  BY KEY2 AS KEY
AFTER MATCH HOLD AS TMP1 OLD-OR NEW
END
-RUN

-*** FILTERING THOSE LEFT IN THE MASTER AND SKIPPED IN THE MATCH
DEFINE FILE FILE1
<TEMP COLUMNS THAT ARE MISSING IN FILE1 BUT ARE IN FILE2 > = '';
END
-RUN

TABLE FILE FILE1
PRINT *
<+ COLUMNS FROM DEFINE>
WHERE <BY_FILEDS> EQ LAST <BY_FIELDS> 
ON TABLE HOLD AS UNMATCHED_MASTER
END
-RUN
TABLE FILE TMP1
PRINT *
ON TABLE HOLD AS TMP1
MORE
FILE UNMATCHED_MASTER
END
-RUN

This message has been edited. Last edited by: Martin_fmi,


WF 7.6.5 / OS: XP / FOCUS
 
Posts: 42 | Registered: September 01, 2008Report This Post
Virtuoso
posted Hide Post
To accomplish that, use
- an initial HOLD to distinguish first vs. later rows for each key in Master,
- a pair of Match files (to hold the first Master record merged against Detail records, and separately hold the remaining master records),
- and finally MORE to combine the MATCH outputs:

-* PULL SPECIMEN MASTER AND DETAIL DATA
TABLE FILE CAR
  COUNT ENTRIES NOPRINT
  BY SEATS AS KEY1
  BY COUNTRY AS ALPHA
  BY CAR     AS BETA
  IF COUNTRY EQ ITALY OR JAPAN
  ON TABLE SET ASNAMES ON AND HOLDLIST PRINTONLY
  ON TABLE HOLD AS MASTER
RUN
  COUNT ENTRIES NOPRINT
  BY SEATS AS KEY2
  BY COUNTRY AS GAMMA
  BY CAR     AS DELTA
  IF COUNTRY EQ ENGLAND
  ON TABLE SET ASNAMES ON AND HOLDLIST PRINTONLY
  ON TABLE HOLD AS DETAIL
END
-RUN

-* now down to business:
-* (SEATS is the "Key"; Key1 and Key2 are included in the matches and final result for clarity)

-* 1. Add sequence number (LIST) to Master record. --> HOLD1
TABLE FILE MASTER
  LIST ALPHA BETA
  BY KEY1
ON TABLE HOLD AS HOLD1
END
-RUN

-* 2. Merge first Master with Detail recordS. --> HOLD2
MATCH FILE HOLD1
  WRITE ALPHA BETA KEY1
  BY KEY1 AS KEY
  IF LIST EQ 1
RUN
FILE DETAIL
  PRINT GAMMA DELTA KEY2
  BY KEY2 AS KEY
  AFTER MATCH HOLD AS HOLD2      OLD-OR-NEW
END
-RUN

-* 3. Nominal "Merge" of the other Master rows with a null Detail record. --> HOLD3, same columns as 2
MATCH FILE HOLD1
  PRINT ALPHA BETA KEY1
  BY KEY1 AS KEY
  IF LIST GE 2
RUN
FILE DETAIL
  PRINT GAMMA DELTA KEY2
  BY KEY2 AS KEY
  IF KEY2 EQ 0
  IF KEY2 NE 0
  AFTER MATCH HOLD AS HOLD3      OLD
END
-RUN

-* 4. combine:
TABLE FILE HOLD2
  PRINT KEY1 ALPHA BETA 
        KEY2 GAMMA DELTA 
  BY KEY UNDER-LINE
MORE
FILE HOLD3
END


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Silver Member
posted Hide Post
Thanks a lot ! If any problems occur later ( probably not ) I will post it here.

This message has been edited. Last edited by: Martin_fmi,


WF 7.6.5 / OS: XP / FOCUS
 
Posts: 42 | Registered: September 01, 2008Report 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] Problem with a specific merging

Copyright © 1996-2020 Information Builders