Class DmlResult (2.21.0)

Represents the result of a data modifying operation using spanner::Client::ExecuteDml().

This class encapsulates the result of a Cloud Spanner DML operation, i.e., INSERT, UPDATE, or DELETE.

Example:
  using ::google::cloud::StatusOr;
  namespace spanner = ::google::cloud::spanner;
  std::int64_t rows_inserted;
  auto commit_result = client.Commit(
      [&client, &rows_inserted](
          spanner::Transaction txn) -> StatusOr<spanner::Mutations> {
        auto insert = client.ExecuteDml(
            std::move(txn),
            spanner::SqlStatement(
                "INSERT INTO Singers (SingerId, FirstName, LastName)"
                "  VALUES (10, 'Virginia', 'Watson')"));
        if (!insert) return std::move(insert).status();
        rows_inserted = insert->RowsModified();
        return spanner::Mutations{};
      });
  if (!commit_result) throw std::move(commit_result).status();
  std::cout << "Rows inserted: " << rows_inserted;

Constructors

DmlResult()

DmlResult(std::unique_ptr< ResultSourceInterface >)

Parameter
NameDescription
source std::unique_ptr< ResultSourceInterface >

DmlResult(DmlResult &&)

Parameter
NameDescription
DmlResult &&

Operators

operator=(DmlResult &&)

Parameter
NameDescription
DmlResult &&
Returns
TypeDescription
DmlResult &

Functions

RowsModified() const

Returns the number of rows modified by the DML statement.

Returns
TypeDescription
std::int64_t