HDL – Query to generate worker email in HDL format
select 'METADATA|PersonEmail|EmailAddressId|PersonId|DateFrom|EmailType|PrimaryFlag|EmailAddress|SourceSystemId|SourceSystemOwner'
from dual
UNION ALL
select 'MERGE|PersonEmail' ||'|'||
NULL ||'|'||
papf.person_id ||'|'||
to_char(ppos.date_start,'RRRR/MM/DD') ||'|'||
'W1' ||'|'||
'Y' ||'|'||
'sendmail-discard_'||papf.person_number||'@xyz.com' ||'|'||
'PER_EMAIL_'||papf.person_number ||'|'||
'HRC_SQLLOADER'
from per_all_people_f papf
,per_periods_of_service ppos
where 1=1
and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
and papf.person_id = ppos.person_id
and ppos.date_start = (select MAX(ppos2.date_start) from per_periods_of_service ppos2
where ppos2.person_id = ppos.person_id)
Sample HDL File:
METADATA|PersonEmail|EmailAddressId|PersonId|DateFrom|EmailType|PrimaryFlag|EmailAddress|SourceSystemId|SourceSystemOwner
MERGE|PersonEmail||100000015400564|2021/03/15|W1|Y|[email protected]|PER_EMAIL_00603|HRC_SQLLOADER