You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
) AS [{{../metadataConfiguration.recordChecksumAttribute}}]
24
+
FROM [{{sourceDataObjects.0.dataObjectConnection.extensions.0.value}}].[{{sourceDataObjects.0.dataObjectConnection.extensions.1.value}}].[{{sourceDataObjects.0.name}}]
25
+
),
26
+
PSA_CTE AS
27
+
(
28
+
SELECT
29
+
A.[{{../metadataConfiguration.recordChecksumAttribute}}] AS [{{../metadataConfiguration.recordChecksumAttribute}}],
30
+
A.[{{../metadataConfiguration.loadDateTimeAttribute}}] AS [{{../metadataConfiguration.loadDateTimeAttribute}}],
31
+
A.[{{../metadataConfiguration.eventDateTimeAttribute}}] AS [{{../metadataConfiguration.eventDateTimeAttribute}}],
32
+
A.[{{../metadataConfiguration.recordSourceAttribute}}] AS [{{../metadataConfiguration.recordSourceAttribute}}],
33
+
{{#each dataItemMappings}}
34
+
A.[{{sourceDataItems.0.name}}] AS [{{targetDataItem.name}}]{{#unless @last}},{{/unless}}
35
+
{{/each}}
36
+
FROM [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] A
MAX({{../metadataConfiguration.loadDateTimeAttribute}}) AS MAX_{{../metadataConfiguration.loadDateTimeAttribute}}
42
+
FROM [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}] B
43
+
GROUP BY {{#each businessKeys}} {{#each businessKeyComponentMapping}}
END AS [{{../metadataConfiguration.recordChecksumAttribute}}],
57
+
CASE
58
+
WHEN STG_CTE.{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}[{{sourceDataItems.0.name}}]{{/if}}{{/each}}{{/each}} IS NULL THEN 'Delete'
59
+
WHEN PSA_CTE.{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}[{{sourceDataItems.0.name}}]{{/if}}{{/each}}{{/each}} IS NULL THEN 'Insert'
60
+
WHEN STG_CTE.{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}[{{sourceDataItems.0.name}}]{{/if}}{{/each}}{{/each}} IS NOT NULL
61
+
AND PSA_CTE.{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}[{{sourceDataItems.0.name}}]{{/if}}{{/each}}{{/each}} IS NOT NULL
62
+
AND STG_CTE.[{{../metadataConfiguration.recordChecksumAttribute}}] != PSA_CTE.[{{../metadataConfiguration.recordChecksumAttribute}}] THEN 'Change' ELSE 'No Change'
63
+
END AS {{../metadataConfiguration.changeDataCaptureAttribute}},
64
+
ROW_NUMBER() OVER
65
+
(ORDER BY
66
+
{{#each businessKeys}}{{#each businessKeyComponentMapping}}CASE WHEN STG_CTE.[{{sourceDataItems.0.name}}] IS NULL THEN PSA_CTE.[{{sourceDataItems.0.name}}] ELSE STG_CTE.[{{sourceDataItems.0.name}}] END{{#unless @last}},{{/unless}}{{/each}}{{/each}}
67
+
) AS {{../metadataConfiguration.sourceRowIdAttribute}},
68
+
CASE
69
+
WHEN STG_CTE.{{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}[{{sourceDataItems.0.name}}]{{/if}}{{/each}}{{/each}} IS NULL
70
+
THEN PSA_CTE.[{{../metadataConfiguration.loadDateTimeAttribute}}]
WHEN {{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}STG_CTE.[{{sourceDataItems.0.name}}] IS NULL THEN 'Delete'{{/if}}{{/each}}{{/each}}
97
+
WHEN {{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}PSA_CTE.[{{sourceDataItems.0.name}}] IS NULL THEN 'Insert'{{/if}}{{/each}}{{/each}}
98
+
WHEN {{#each businessKeys}}{{#each businessKeyComponentMapping}}{{#if @first}}PSA_CTE.[{{sourceDataItems.0.name}}] IS NOT NULL AND PSA_CTE.{{sourceDataItems.0.name}} IS NOT NULL AND STG_CTE.[{{../../../metadataConfiguration.recordChecksumAttribute}}] != PSA_CTE.[{{../../../metadataConfiguration.recordChecksumAttribute}}] THEN 'Change'{{/if}}{{/each}}{{/each}}
99
+
ELSE 'No Change'
100
+
END
101
+
) != 'No Change'
102
+
)
103
+
INSERT INTO [{{targetDataObject.dataObjectConnection.extensions.0.value}}].[{{targetDataObject.dataObjectConnection.extensions.1.value}}].[{{targetDataObject.name}}]
0 commit comments