Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 05:31 AM
I am still wondering what you mean by 500+ lines of code for a merge.
do you mean the list of columns which should be updated?
If you want to update a subset of columns that can become cumbersome indeed. But with some coding in scala/python you can create a list of column names which you can then pass to the query.
If you want to update all, use *
MERGE INTO table
USING updates
ON mgline.RegistrationYear IN ($yearlist) AND
table.key1 = updates.key1 and
table.key2 = updates.key2 and
table.key3 = updates.key3
WHEN MATCHED THEN
UPDATE SET *
WHEN NOT MATCHED THEN
INSERT *