![]() |
||||||||||||
Go ![]() | New ![]() | Search ![]() | Notify ![]() | Tools ![]() | Reply ![]() | ![]() |
Platinum Member |
See the following example using JOIN: -* PFMIKPCR - FOCEXEC - 2004.04.07 - Mikel G�mez - Producto cartesiano. -* _____________________________________________________________________ -* Test files generation for problem repro. -* Test FILE 1. TABLE FILE CAR BY COUNTRY AS 'FIELD1' ON TABLE HOLD AS FILE1 ON TABLE SET ASNAMES ON END -RUN -* Test FILE 2. TABLE FILE CAR BY CAR AS 'FIELD2' ON TABLE HOLD AS FILE2 ON TABLE SET ASNAMES ON END -RUN -* _____________________________________________________________________ -* Objectives. -* Now, we have: -* FILE1, FIELD1: ENGLAND, FRANCE..., 5 values. -* FILE2, FIELD2: ALFA, AUDI..., 10 values. -* -* And we need the cartesian product: -* FILE3, 5 x 10 = 50 records. -* -* Steps: -* 1. Create temp file of second file with common blank index. -* 2. Join first and temp file using the common blank index using TO ALL. -* 3. Create the cartesian product. -* _____________________________________________________________________ -* Index second file with common blank index. TABLE FILE FILE2 COMPUTE KEY/A1 = ' ' ; FIELD2 ON TABLE HOLD AS FILE2IND FORMAT FOCUS INDEX KEY END -RUN -* _____________________________________________________________________ -* 2. Join files using common blank index. (*** TO ALL ***) JOIN CLEAR * JOIN KEY WITH FIELD1 IN FILE1 TO ALL KEY IN FILE2IND AS J1 -* _____________________________________________________________________ -* 3. Create and show cartesian product. DEFINE FILE FILE1 KEY/A1 WITH FIELD1 = ' ' ; END TABLE FILE FILE1 FIELD1 FIELD2 END -RUN I hope this helps. Regards, MikelThis message has been edited. Last edited by: <Mabel>, | |||
|
<Stahl> |
Super trouper, Mikel! That was exactly what I needed. Thanks a lot! Stahl | ||
|
Platinum Member |
Have you tried the command.. SET CARTESIAN=ON | |||
|
<Stahl> |
Yes, I did, but it didn't work. Maybe I made a mistake | ||
|
Platinum Member |
SET CARTESIAN is not applicable in this case. In this topic we haven't path. We have two unrelated files without any common field. We must create the path properly. Regards, Mikel | |||
|
Powered by Social Strata |
![]() | Please Wait. Your request is being processed... |
|