Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Joining to a table with effective dates/terms
Go
New
Search
Notify
Tools
Reply
  
[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: 11 | Registered: June 16, 2016Reply With QuoteReport 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 7.7.05M, 8.1.05M, 8.2.0.1M gen240 Windows, HTML, Excel, PDF
In Focus since 2007
 
Posts: 1825 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport 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: 56 | Registered: October 31, 2006Reply With QuoteReport 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: 11 | Registered: June 16, 2016Reply With QuoteReport 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 7.7.05M, 8.1.05M, 8.2.0.1M gen240 Windows, HTML, Excel, PDF
In Focus since 2007
 
Posts: 1825 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport 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: 11 | Registered: June 16, 2016Reply With QuoteReport 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: 83 | Location: MI | Registered: July 23, 2009Reply With QuoteReport This Post
  Powered by Social Strata  
 

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-2018 Information Builders, leaders in enterprise business intelligence.