Closed obabichevjb closed 1 month ago
This PR introduces a new mergeFrom method query method, allowing execute underlying sql merge command. The merge method supports merging data from one table or select query into another table, with conditional logic for matched and unmatched rows.
mergeFrom
The method can be used in the following way:
Dest.mergeFrom(Source, on = { Source.key eq Dest.key() }) { whenNotMatchedInsert { it[Dest.key] = Source.key it[Dest.value] = Source.value } whenMatchedDelete(and = (Source.value eq 1)) whenMatchedUpdate(and = (Source.value eq 1)) { it[Dest.key] = Source.key it[Dest.value] = (Dest.value + Source.value) * 10 } }
Merge command is supported by the databases: SQL Server, Postgres, Oracle, H2
Please update the PR description
Updated
This PR introduces a new
mergeFrom
method query method, allowing execute underlying sql merge command. The merge method supports merging data from one table or select query into another table, with conditional logic for matched and unmatched rows.The method can be used in the following way:
Merge command is supported by the databases: SQL Server, Postgres, Oracle, H2