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] Joining to a table with effective dates/terms

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Joining to a table with effective dates/terms
 Login/Join
 
Member
posted
I'm working on pulling information about faculty from a table that is organized with an effective term. Historically we have used MATCH FILE to get the relevant effective term, then MATCH FILE *again* using that retrieved term to collect the information from the relevant records. This is really getting out of hand both in terms of resources consumed and the difficulty in maintaining and updating the reports that use this method for multiple effective-term tables.

I have begun using conditional joins to simplify many of our existing reports, but I can't figure out how to ensure that a join will pick up the correct record. Here is what I am envisioning, field and file names altered for readability:

JOIN LEFT_OUTER
FILE FACULTYASSIGNMENTS	AT FACULTYASSIGNMENTS_ID	TAG ASG 	TO ONE
FILE FACULTYDETAIL	AT FACULTYDETAIL_ID		TAG DET 	AS JFDE
WHERE ASG.FACULTYASSIGNMENTS_ID EQ DET.FACULTYDETAIL_ID;
WHERE DET.FACULTYDETAIL_EFFECTIVETERM LE &CURRENT_TERM;
WHERE DET.FACULTYDETAIL_EFFECTIVETERM {***IS THE HIGHEST OF THE AVAILABLE RECORDS***};
END


What can I do to get a join to identify the record with the highest effective term?

I have found this example SQL code that accomplishes this task, but I'm unsure of how I would implement it in a FOCUS join (different field names taken directly from example):

WHERE NOT EXISTS
(
    SELECT *
    FROM Vat_Rate_Details VRD2
    WHERE
        VRD2.rate_id = VR.rate_id AND
        VRD2.effect_date < NOW() AND
        VRD2.effect_date > VRD1.effect_date
)

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8202
Windows, All Outputs
 
Posts: 12 | Registered: June 16, 2016Report This Post
Virtuoso
posted Hide Post
If you already have the code in SQL, you can use "SQL pass through" : several post and doc on the subject.

Or you may have to first extract the "highest of the available records" to have them used in your JOIN as a joined file
Or extract the highest date, set a variable to this value and use this new variable in your WHERE clause
Or ...

Many other option may exist but difficult to tell since we don't know how your data is organized and their relationship.


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
Gold member
posted Hide Post
+1 for
Or extract the highest date, set a variable to this value and use this new variable in your WHERE clause

I presume you have a table you can hit where you can retrieve a single row with the value of the start of the effective term. if you need to grab the ending date at the same time, do that so they end up in one row (2 columns).

Then -READ the dates into a & variables so you can use the &STARTEFFDATE and &ENDEFFDATE in your code.

If you find that you need this date range often, I would put this in it's own focexec so you can -INCLUDE it anytime to create those two dates for you. If you use it VERY often, you might even decide to go with && global variables set from EDASPROF so that those variables are always available to all procedures.

Good luck!
Toby Mills, CISSP
 
Posts: 62 | Registered: October 31, 2006Report This Post
Member
posted Hide Post
quote:
Originally posted by MartinY:
Or you may have to first extract the "highest of the available records" to have them used in your JOIN as a joined file


Okay, this gave me ideas. I can use a MATCH to look up the most recent effective term in FACULTYDETAIL for each person in my query without including any of the other information I'll be reporting on. That keeps my runtime short. I can then JOIN to the hold file I just created to use those effective terms (unique for each individual - each person gets a new effective term when the terms of their employment change) in my JOIN to FACULTYDETAIL to get the rest of the relevant information.

I would still prefer to avoid using a MATCH to do this, but I've at least significantly improved the performance of this report. This change also improves the legibility of the code.

Thank you for the suggestion!


WebFOCUS 8202
Windows, All Outputs
 
Posts: 12 | Registered: June 16, 2016Report This Post
Virtuoso
posted Hide Post
quote:
I can use a MATCH to look up the most recent effective term in FACULTYDETAIL for each person

Why the needs to use MATCH ?

Can you not just use something such as
TABLE FILE FACULTYDETAIL
SUM MAX.EFFECTIVETERM
BY PERSON
ON TABLE HOLD AS MAXEFF FORMAT FOCUS INDEX PERSON
END
-RUN

Then use MAXEFF file in the JOIN


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
Member
posted Hide Post
quote:
Why the needs to use MATCH ?


You're right. This table is not so large that I'm saving any effort trying to query only a subset of it. I could do what you say here and produce a hold file that simply indexes the appropriate EFF_TERM for everyone. This would work on nearly every table I work with. Only 1 or 2 of our tables are so bloated that I would want to limit it to relevant people.

Thanks a million!


WebFOCUS 8202
Windows, All Outputs
 
Posts: 12 | Registered: June 16, 2016Report This Post
Gold member
posted Hide Post
Another option is to join LIMITING_TABLE and EFFECTIVE_TERM_TABLE, and then

PRINT FIELDS FROM JOIN
BY HIGHEST 1 EFFECTIVE_TERM
WHERE EFFECTIVE_TERM LE CURRENT_TERM


- Rob


WebFocus 8201m on Windows; App Studio 8201; Procedures: WebFocus with SQL; HTML Parameter Pages & Dashboard; Output: Excel, HTML, & PDF.
 
Posts: 88 | Location: MI | Registered: July 23, 2009Report 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] Joining to a table with effective dates/terms

Copyright © 1996-2020 Information Builders