The view updates represents an incremental batch of all newly ingested data to be inserted or updated in the customers table.
The following logic is used to process these records.
MERGE INTO customers
USING (
SELECT updates.customer_id as merge_ey, updates .*
FROM updates
UNION ALL
SELECT NULL as merge_key, updates .*
FROM updates JOIN customers
ON updates.customer_id = customers.customer_id
WHERE customers.current = true AND updates.address <> customers.address
) staged_updates
ON customers.customer_id = mergekey
WHEN MATCHED AND customers. current = true AND customers.address <> staged_updates.address THEN
UPDATE SET current = false, end_date = staged_updates.effective_date
WHEN NOT MATCHED THEN
INSERT (customer_id, address, current, effective_date, end_date)
VALUES (staged_updates.customer_id, staged_updates.address, true, staged_updates.effective_date, null)
Which statement describes this implementation?
Alishia
9 months agoAnjelica
9 months agoDalene
9 months agoJanessa
10 months agoOzell
10 months agoTruman
10 months agoCarlota
10 months agoRhea
10 months agoGlendora
11 months agoDeeann
11 months agoZona
11 months agoPearline
11 months agoCarri
11 months agoEttie
11 months agoBrandon
11 months agoYoulanda
11 months agoZoila
11 months agoCatherin
2 years agoSueann
2 years agoCatarina
2 years agoSueann
2 years agoGeorgeanna
2 years agoKallie
2 years agoCarma
2 years agoGeorgeanna
2 years agoKallie
2 years ago