MERGE Statement
Translation reference to convert Oracle MERGE statement to Snowflake Scripting
Last updated
Translation reference to convert Oracle MERGE statement to Snowflake Scripting
Last updated
The
MERGE
statement is used to select rows from one or more sources for update or insertion into a table or view. It is possible to specify conditions to determine whether to update or insert into the target table or view. This statement is a convenient way to combine multiple operations. It lets to avoid multipleINSERT
,UPDATE
, andDELETE
DML statements.MERGE
is a deterministic statement. It is not possible to update the same row of the target table multiple times in the sameMERGE
statement. ())
In order to find an equivalence for the DELETE statement and the where clause, it is necessary to reorder and implement some changes in the Snowflake merge statement.
Replace the Oracle's DELETE where_clause with a new Snowflake's matchedClause with the AND predicate statement
Replace the where_clause from the Oracle's merge_insert_clause with an AND predicate statement in the Snowflake's notMatchedClause
In some cases the changes applied may do not work as expected, like the next example:
There is no equivalent for the error logging clause in Snowflake Scripting.
Sometimes, the changes applied in order to achieve the functional equivalence between Oracle's merge statement and Snowflake's do not work as expected.
: Number type column may not behave similarly in Snowflake.
: Merge statement may not work as expected