select ct.* -- specify change tracking fields here.
from pub.”_File” f inner join pub."_Cdc-Change-Tracking" ct on f."_File-Number" = ct."_Source-Table-Number" where f."_file-name" = ‘customer’ and f."_Owner" = ‘pub’ order by ct.”_Source-Table-Number", ct." _Change-Sequence"; -- sort keys map to index _Sequence-Id |
select ct.* -- specify change tracking fields here.
from pub.”_File” f inner join pub."_CDC-Table-Policy" tp on f.rowid = tp.”_Source-File-Recid” and tp."_Policy-Instance" = 0 -- Policy is current. inner join pub."_Cdc-Change-Tracking" ct on f."_File-Number" = ct."_Source-Table-Number" and tp.”_Policy-Id” = ct.”_Policy-Id” where f."_file-name" = ? -- table name parameter from ETL app. and f."_Owner" = ? -- table name parameter from ETL app. order by ct."_Source-Table-Number", ct." _Change-Sequence"; |
-- Step 1 – get one row with CDC policy id, source table number
select tp."_Policy-Id", f."_File-Number" --for step 2 query. from pub.”_File” f inner join pub."_CDC-Table-Policy" tp on f.rowid = tp.”_Source-File-Recid” and tp."_Policy-Instance" = 0 -- Policy is current. where f."_file-name" = ? -- table name parameter from ETL app. and f."_Owner" = ? ; -- table name parameter from ETL app. -- Step 2 select ct.* -- specify change tracking fields here. from pub."_Cdc-Change-Tracking" ct where ct."_Source-Table-Number" = ? -- source table number from step 1 and ct."_Policy-Id" = ? -- Table policy id parameter from step 1 order by ct."_Source-Table-Number", ct." _Change-Sequence"; -- maps to index _Sequence-Id |