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     Antijoin in master-file. Can I define something like NOT EXISTS?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Antijoin in master-file. Can I define something like NOT EXISTS?
 Login/Join
 
Gold member
posted
Hi all

I can't find a possibility to define in master file something like:

SELECT Customer_id FROM Sales S
WHERE
NOT EXISTS(
SELECT customer_id FROM customer C
WHERE
S.customer_id = C.customer_id
)

(Find all incorrect record in sales table for nonexistent customer)

I do no see such option in WF-joins
Also I saw a filter function EXCLUDES - but it's more like NOT IN (...)

Maybe I'm mistaken - can somebody guide me in right direction?


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
 
Posts: 79 | Location: Moscow | Registered: April 27, 2007Report This Post
Expert
posted Hide Post
I do not think that you can achieve what you want within the master file description using DEFINEs - someone will now prove me wrong. You certainly can not use SQL statements.

You could try
JOIN CLEAR *
JOIN LEFT_OUTER Customer_id IN Sales TAG S TO customer_id IN customer TAG C AS J1.
TABLE FILE Sales
PRINT S.Customer_id
WHERE C.customer_id IS MISSING
END

or you could include the SQL within the focexec itself using SQL passthru, many examples of which exist in the many topics and posts on this forum.

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
Gold member
posted Hide Post
Yes, I know that I can't use SQL in master file definitions.
In fact, I've asked about equivalent Focus statement.
(I'm novice in Focus)

Thank you for your advice, in fact it's equivalent in SQL to:

SELECT S.Customer_id
FROM
SALES S
LEFT OUTER JOIN customer C ON S.customer_id = S.customer_id
WHERE
C.customer_id IS NULL

It's equivalent to NOT EXISTS statement, but from my experience NOT EXISTS sometimes works faster then LEFT OUTER JOIN (in MSSQL)
I've thought in Focus exists something like antijoin.

(Now I'm looking for something like Oracle antiunion - select from multiple sources only different records)

SQL Passthru - is not possible when sources from different connections.


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
 
Posts: 79 | Location: Moscow | Registered: April 27, 2007Report This Post
Virtuoso
posted Hide Post
Ingas,

There is no way that I know of to write FOCUS code that will translate into SQL code that contains a subquery in a WHERE clause. IBI Tech Support would be the best people to ask about this but I have never seen this in any information I have read about FOCUS to RDBMS efficiencies.

I'm not sure what this will translate to as far as SQL but this is another way to accomplish the same thing. Be careful of the limits on how many values can be in the VALIDVALUES file. The limit with an IF selection is 32,767 according to the WF 7.1 manual. This will create a large SQL request depending on how many values there are in the VALIDVALUES list.

TABLE FILE CAR
SUM COUNTRY NOPRINT
BY COUNTRY
WHERE COUNTRY EQ 'ENGLAND' OR 'W GERMANY'
ON TABLE SAVE AS VALIDVALUES
END
-RUN
TABLE FILE CAR
PRINT COUNTRY CAR MODEL BODYTYPE
IF COUNTRY IS-NOT (VALIDVALUES)
END


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Virtuoso
posted Hide Post
For a 1-1 join, you can define fields based on the values in the virtual (joined-to) segment, and the define will be evaluated whether or not an actual instance is located, as though an instance had been retieved whose fields are all blank or zero.

JOIN COUNTRY IN HOLD TO COUNTRY IN CAR
DEFINE FILE HOLD
TAKE/I1 = CAR.ORIGIN.COUNTRY EQ ' ';
END
TABLE FILE HOLD
PRINT *
IF TAKE IS TRUE
END


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Gold member
posted Hide Post
Thanks to all for help!

I've understood how this can be accomplished.

LEFT OUTER JOIN and IS MISSING is what I've search

Variant with virtual field, then filtering this field - also looks good for me


WF 7.6.2, WinNT/2K, MSSQL 2K, MSOLAP 2K, BID
 
Posts: 79 | Location: Moscow | Registered: April 27, 2007Report This Post
Platinum Member
posted Hide Post
I believe the easiest way to do this is to use the 'ALL' operation.

JOIN CUSTOMER_ID IN SALES TO CUSTOMER_ID IN CUSTOMER
TABLE FILE SALES
PRINT ALL CUSTOMER_ID
WHERE CUSTOMER.CUSTOMER_ID IS MISSING ;
END


Release 7.6.9
Windows
HTML
 
Posts: 226 | Registered: June 08, 2003Report This Post
Platinum Member
posted Hide Post
Forgot to add the 'dot.
Make it PRINT ALL.CUSTOMER_ID


Release 7.6.9
Windows
HTML
 
Posts: 226 | Registered: June 08, 2003Report This Post
Master
posted Hide Post
And of course, there's always MATCH.

MATCH FILE SALES
SUM SALE_TOTAL
BY CUSTOMER_ID
RUN
FILE CUSTOMER
SUM CUSTOMER_NAME
BY CUSTOMER_ID
AFTER MATCH HOLD OLD-NOT-NEW
END


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Virtuoso
posted Hide Post
MATCH FILE will work but will probably pull all the data from the RDBMS over to FOCUS before trying to compare. That will take a LOOONNNGGG time.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Master
posted Hide Post
Mickey,

True, it could take a long time depending on the number or rows in each table. However, assuming this is a relational database, having a foreign key relationship between the 2 tables eliminates the need for the query because one could not insert a row the SALES table before the customer was added to the CUSTOMER table.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report 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     Antijoin in master-file. Can I define something like NOT EXISTS?

Copyright © 1996-2020 Information Builders