Merge is another DML command just like INSERT/UPDATE/DELETE, so it should be manually committed unless it is not a part of BEGIN....END transaction.
nnani=> select * from navin.Test1; id | name ----+------ 2 | sbc 3 | cbc 1 | abc 4 | dbc 5 | ebc (5 rows) nnani=> select * from navin.Test2; id | name ----+------ 1 | abc 6 | gbc (2 rows)
Now we will run a merge command to update the Test2 table with new records.
nnani=> MERGE INTO navin.Test2 T2 USING navin.Test1 T1nnani-> ON T2.ID = T1.ID nnani-> WHEN MATCHED THEN nnani-> UPDATE SET nnani-> ID = T1.ID, nnani-> NAME = T1.NAME nnani-> WHEN NOT MATCHED THEN nnani-> INSERT nnani-> (ID, NAME ) VALUES (T1.ID, T1.NAME); OUTPUT -------- 5 (1 row)
Lets check if the records are autocommited. Opening a new session and checking .
nnani=> select * from navin.Test2; id | name ----+------ 1 | abc 6 | gbc (2 rows) nnani=>
The records are not committed, unless you execute a explicit COMMIT statement
Comments
Because in document it's not mentioned that you need to issue a
COMMIT
orROLLBACK
command to finish the transaction like INSERT has.Merge is another DML command just like INSERT/UPDATE/DELETE, so it should be manually committed unless it is not a part of BEGIN....END transaction.
Now we will run a merge command to update the Test2 table with new records. Lets check if the records are autocommited. Opening a new session and checking .
The records are not committed, unless you execute a explicit COMMIT statement Now the records are committed.
Hope this helps