Skip to content

Support nested updates #252

@apstndb

Description

@apstndb

https://cloud.google.com/spanner/docs/reference/standard-sql/dml-syntax?hl=en#nested-updates-protocol-buffers

UPDATE Singers s
SET
    (DELETE FROM s.SingerInfo.Residence r WHERE r.City = 'Seattle'),
    (UPDATE s.SingerInfo.Residence r SET r.end_year = 2015 WHERE r.City = 'Eugene'),
    (INSERT s.Albums.Song VALUES ("songtitle: 'The Second Best Song'"))
WHERE SingerId = 3 AND s.Albums.title = 'Go! Go! Go!';

Note

The formal syntax is not yet well described in the Spanner DML syntax reference, but we can reference ZetaSQL DML syntax reference.

https://github.com/google/zetasql/blob/2024.11.1/docs/data-manipulation-language.md#update-statement

UPDATE target_name
SET set_clause
[FROM from_clause]
WHERE condition [ASSERT_ROWS_MODIFIED n] [ then_return_clause ]

set_clause:
  update_item[, ...]

update_item:
  {
    path_expression = expression
    | path_expression = DEFAULT
    | (dml_stmt)
  }

...

dml_stmt:
  { insert_statement | update_statement | delete_statement }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions