Tuesday, January 21, 2014

Effective date checking

%EffDtCheck

The %EffDtCheck construct expands into an effective date subquery suitable for a Where clause.

Only use the %effdtchk when a table DOES NOT have effective sequence effseq in the key.


Syntax

%EffDtCheck(recordname [correlation_id1], correlation_id2, as_of_date)

Example

  1. &q = select 'x' from ps_genl_deduction A where A.emplid = :1 and %EffDtCheck(:2 B, A, %CurrentDateIn)
  2. SQLExec(&q, &emplid, Record.GENL_DEDUCTION, &result);
Expands to:
  1. select 'x' from ps_genl_deduction A where A.emplid = '0001'
  2. where A.EFFDT = (SELECT MAX(EFFDT) FROM PS_GENL_DEDUCTION
  3. WHERE B.KEYFIELD1 = A.KEYFIELD1 AND B.KEYFIELD2 = A.KEYFIELD2 AND. . .
  4. AND B.EFFDT <= %DATEIN([current date]))
   

No comments:

Post a Comment