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’ and ct."_Time-Stamp" between ? and ? -- time range parameter values 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. and ct."_Time-Stamp" between ? and ? -- time range parameter values order by ct."_Change-Sequence"; |
-- Step 1 – give one row with CDC policy id, source table number
select ct."_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 and ct."_Time-Stamp" between ? and ? -- time range parameter values order by ct."_Source-Table-Number", ct."_Time-Stamp", ct." _Change-Sequence"; -- maps to index __Time-Stamp-Seq |