PS/Query does warn you that it has added the criteria, but it won't warn that the column is not a key column
If EFFDT is not part of the key, then it is unlikely that you will need this processing. It is unlikely to change the result of the query, and it incurs additional work.
Below is an example of the code added to a query by this one criteria. The effective date sub-query will be correlated by the key columns prior to the EFFDT column. If EFFDT is not part of the key, then all the key columns will be used for the correlation conditions. There is only one row for each EMPLID and EMPL_RCD, and the effective date sub-queries will find and return that row, and the result set will remain the same.
... AND ( a.effdt = (SELECT MAX(a_ed.EFFDT) FROM ps_employees a_ed WHERE a.emplid = a_ed.emplid AND a.empl_rcd = a_ed.empl_rcd AND a_ed.EFFDT <= SYSDATE) AND a.effseq = (SELECT MAX(a_es.EFFSEQ) FROM ps_employees a_es WHERE a.emplid = a_es.emplid AND a.empl_rcd = a_es.empl_rcd AND a.effdt = a_es.EFFDT) ) ...
But how prevalent is this problem? Like most things in PeopleSoft, Queries are stored in the PeopleTools tables. And it is possible to construct a query to identify queries with effective date criteria on EFFDT columns that are not part of the key on their record.
SELECT c.oprid, c.qryname, r.recname, r.corrname, f.fieldname --, useedit, bitand(d.useedit,1) FROM psqrycriteria c /*query crieria*/ , psqryrecord r /*records in queries*/ , psqryfield f /*fields in a queries*/ , psrecfielddb d /*fields on records, with sub-records fully expanded*/ WHERE c.condtype BETWEEN 20 AND 25 /*effdt criteria, so no need to specify column name*/ AND c.lcrtfldnum = f.fldnum -- AND r.oprid = c.oprid AND r.qryname = c.qryname AND r.selnum = c.selnum -- AND f.oprid = c.oprid AND f.qryname = c.qryname AND f.selnum = c.selnum -- AND f.oprid = r.oprid AND f.qryname = r.qryname AND f.selnum = r.selnum AND f.recname = r.recname -- AND d.recname = f.recname AND d.fieldname = f.fieldname AND BITAND(d.useedit,1) = 0 /*a non-key field*/
ORDER BY 1,2 /
On my HR demo database the following delivered queries have effective date criteria on EFFDT columns that are no key columns.
OPRID QRYNAME RECNAME CORRN FIELDNAME -------- ------------------------------ --------------- ----- --------- JPM_INACTIVE_CONTENT_ITEMS JPM_JP_CRITM_VW A EFFDT JPM_PERS_PROFILE JPM_JP_CRITM_VW F EFFDT JPM_PROFILE JPM_JP_CRITM_VW F EFFDT NOT001 FPAEEFLAT_TBL A EFFDT
Now, it is possible to review these queries and manually remove the effective date processing if that is appropriate.
No comments :
Post a Comment