1
votes

Does google cloud Spanner supports Merge statements like Oracle?

For example I have SQL' like below. Will it work ? I am getting INVALID ARGUMENT while running the snippet.

merge P1 c using (select sumery.RunId from PS sumery where sumery.RunId=1010192) s on (c.LastRunId=s.RunId) when MATCHED THEN udpate c.ProcessTypeCd ='Update' WHEN NOT MATCHED THEN INSERT INTO P1 (ProcessName, ActiveF, InProgressF) VALUES('12', 'Y', 'N');

1

1 Answers

2
votes

No, Cloud Spanner only supports INSERT, UPDATE and DELETE DML statements. It does however support InsertOrUpdate mutations which has the same semantics as a MERGE statement.

Your question does not include any information how and/or with which programming language you are connecting to Cloud Spanner, but all the client libraries and the JDBC driver for Cloud Spanner support writing mutations. A sample for writing with mutations can be found here: https://cloud.google.com/spanner/docs/samples/spanner-insert-data