user3702620
user3702620

Reputation: 45

Does Google spanner supports merge statements

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');

Upvotes: 1

Views: 663

Answers (1)

Knut Olav Løite
Knut Olav Løite

Reputation: 3512

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

Upvotes: 1

Related Questions