Class DmlResult (2.28.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
Name Description
source std::unique_ptr< ResultSourceInterface >

DmlResult(DmlResult &&)

Parameter
Name Description
DmlResult &&

Operators

operator=(DmlResult &&)

Parameter
Name Description
DmlResult &&
Returns
Type Description
DmlResult &

Functions

RowsModified() const

Returns the number of rows modified by the DML statement.

Returns
Type Description
std::int64_t