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] Conditional Join

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Conditional Join
 Login/Join
 
Member
posted
I need to conditionally join two files when field1 in file1 'contains' field2 in file2. 'field' is not an option when I select the 'contains' LogicalRelation in Expression Builder. Is there another way?

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


WF 7702
 
Posts: 9 | Registered: June 27, 2012Report This Post
Expert
posted Hide Post
Have you tried a conditional join ?

e.g.
JOIN INNER|LEFT_OUTER
FILE file1 AT field1 [TAG tag1] TO UNIQUE|MULTIPLE
FILE file2 AT field2 [TAG tag2] AS jointag
[WHERE tag1.field1 CONTAINS tag2.field2 ;]
END  


I think this CONTAINS works, if it doesn't, leave the WHERe out and add the WHER clause to the TABLE request.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Virtuoso
posted Hide Post
But be careful with trailing blanks in field2 --
"applesauce  " CONTAINS "apple   "
 ^^^^^^^^^^^^            ^^^^^^^^
is False


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
I tried the WHERE clause in both the conditional join and then at the TABLE level. Got the same result for both which was as if I had used EQ instead of CONTAINS.

Conditional Join:

-* File iscd_home_performance_dropdown_1_2.fex
-SET &ECHO=ALL;
-DEFAULT &SRV_KEY01 = '0.0.1.0.77.0.1';
JOIN
INNER FILE ISDIMSERVICE AT ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY TO MULTIPLE
FILE ISMETRICMASTER AT ISMETRICMASTER.ISMETRICMASTER.DIDSERVICEKEY TAG J1 AS J1
WHERE ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY CONTAINS J1.ISMETRICMASTER.DIDSERVICEKEY;
END
TABLE FILE ISDIMSERVICE
PRINT
ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY
J1.ISMETRICMASTER.METRICKEY
J1.ISMETRICMASTER.DIDSERVICEKEY
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=REPORT,
LINES-PER-PAGE=20,
$
ENDSTYLE
END


WHERE clause on the TABLE:

* File iscd_home_performance_dropdown_1_2.fex
-SET &ECHO=ALL;
-DEFAULT &SRV_KEY01 = '0.0.1.0.77.0.1';
JOIN
FILE ISDIMSERVICE AT ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY TO MULTIPLE
FILE ISMETRICMASTER AT ISMETRICMASTER.ISMETRICMASTER.DIDSERVICEKEY TAG J1 AS J1
END
TABLE FILE ISDIMSERVICE
PRINT
ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY
J1.ISMETRICMASTER.METRICKEY
J1.ISMETRICMASTER.DIDSERVICEKEY
WHERE ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY CONTAINS J1.ISMETRICMASTER.DIDSERVICEKEY;
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=REPORT,
LINES-PER-PAGE=20,
$
ENDSTYLE
END


WF 7702
 
Posts: 9 | Registered: June 27, 2012Report This Post
Virtuoso
posted Hide Post
quote:
as if I had used EQ instead of CONTAINS.

Meaning, the record is pulled only when ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY and ISMETRICMASTER.ISMETRICMASTER.DIDSERVICEKEY contain identical values.

You're just not paying attention: The trailing blanks are treated as part of the value, so a "CONTAINS" comparison of two fields yields "true" only when both fields have identical contents.

Rather than using "CONTAINS", use functions -- ARGLEN to determine the trimmed length of the second field's value, and POSIT to test whether the first field's value contains the leading portion of the second field's value, up to the latter's trimmed length.

If the keys are declared as char (An), this should do it:
 
WHERE
 POSIT(ISDIMSERVICE.ISDIMSERVICE.DIDSERVICEKEY, 
       n,
       ISMETRICMASTER.ISMETRICMASTER.DIDSERVICEKEY, 
       ARGLEN(n, ISMETRICMASTER.ISMETRICMASTER.DIDSERVICEKEY, 'I5'),
       'I5') 
  NE 0; 


If varchar (AnV), you may have to use corresponding funtions designed for use with varchar fields.

Whether WebFocus is clever enough to translate that test to SQL and pass it on to the server, you can only determine by obtaining a statement trace.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
Is there a way to use the contents of a field as the comparison pattern to use in a 'like' in a conditional join or really any WHERE clause?


WF 7702
 
Posts: 9 | Registered: June 27, 2012Report This Post
Expert
posted Hide Post
I think you can do this with a function on the tested value, will check.

Jack's suggestion is probably the best way to go.

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


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Member
posted Hide Post
Thanks, that works.


WF 7702
 
Posts: 9 | Registered: June 27, 2012Report 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] Conditional Join

Copyright © 1996-2020 Information Builders