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]: WEBFOCUS CONDITIONAL JOIN - SQL QUERY

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]: WEBFOCUS CONDITIONAL JOIN - SQL QUERY
 Login/Join
 
Platinum Member
posted
HI,
Please see the SQL query below:

--******************************

SELECT a.*,b.*
FROM a
inner join b
on (case when isnull(a.r_key,'') = '' and b.r_key <> '' then 1 when isnull(a.r_key,'') <> '' and a.r_key = b.r_key then 1 else 0 end) = 1
and (case when isnull(a.c_key,'') = '' and b.c_key <> '' then 1 when isnull(a.c_key,'') <> '' and a.c_key = b.c_key then 1 else 0 end) = 1
and (case when isnull(a.m_key,'') = '' and b.m_key <> '' then 1 when isnull(a.m_key,'') <> '' and a.m_key = b.m_key then 1 else 0 end) = 1

--*******************************


The scenario is master file "a" has 3 fields r_key, m_key, c_key. Each of these fields could have NULL or a value.
I want to join it to table b so that if there is a value in table a then join to table b otherwise take all the values from table b.
I want to create a schema with the join like the SQL above in webfocus.
The query above gives me the the expected result but not sure how to convert it into webfocus language when joining 2 master files to create a schema.

SEGMENT=a, SEGTYPE=KU, PARENT=b, CRFILE=b, CRINCLUDE=ALL, CRJOINTYPE=INNER,
JOIN_WHERE=(a.R_KEY EQ b.R_KEY) AND (a.C_KEY EQ b.C_KEY) AND ((IF a.M_KEY EQ '' AND b.M_KEY NE '' THEN 1 ELSE IF a.M_KEY <> '' and a.M_KEY= b.M_KEY THEN 1 ELSE 0) EQ 1) ;, $

The statement above gives me an error.
Is it possible to do something like that or is there another approach that gives me the result as the SQL query.


Thanks,

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


WebFOCUS 8202M
 
Posts: 167 | Location: Montreal | Registered: September 23, 2014Report This Post
Virtuoso
posted Hide Post
This look like you need to perform a MATCH FILE using AFTER MATCH NEW option


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, 2013Report This Post
Master
posted Hide Post
You need to create a define field in the master for your case statement. Then in your JOIN_WHERE, instead of referencing your case statement, you reference your define field.

But, assuming that all you did was remove the field names and this is your actual statement, then it seems like you have over engineered this and can be done with a simpler join. I would construct it like this and call it a day

JOIN_WHERE =( (A.R_KEY IS MISSING AND B.R_KEY IS MISSING) OR (A.R_KEY = B.R_KEY) ) AND ( (A.C_KEY IS MISSING AND B.C_KEY IS MISSING) OR (A.C_KEY = B.C_KEY) ) AND ( (A.M_KEY IS MISSING AND B.M_KEY IS MISSING) OR (A.M_KEY = B.M_KEY) )  


No need to play around with conditional joins. Didn't even need to add the complication in SQL. Not sure why you did.


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
 
Posts: 750 | Location: Warrenville, IL | Registered: January 08, 2013Report This Post
Platinum Member
posted Hide Post
Thanks Eric.
I had started with the Define fields but the SQL conversion for some reason was using the wrong fields. I am going to look into in more detail and open a CASE if need be.

you are right .. as usual I was over complicating it Smiler.
here is the statement I used (modified your suggestion a bit) and it works beautifully. thanks

JOIN_WHERE =
( (A.R_KEY IS MISSING AND B.R_KEY IS NOT MISSING) OR (A.R_KEY = B.R_KEY) )
AND ( (A.C_KEY IS MISSING AND B.C_KEY IS NOT MISSING) OR (A.C_KEY = B.C_KEY) )
AND ( (A.M_KEY IS MISSING AND B.M_KEY IS NOT MISSING) OR (A.M_KEY = B.M_KEY) )


WebFOCUS 8202M
 
Posts: 167 | Location: Montreal | Registered: September 23, 2014Report 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]: WEBFOCUS CONDITIONAL JOIN - SQL QUERY

Copyright © 1996-2020 Information Builders