Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
Loading...
Searching...
No Matches
Public Member Functions | List of all members
google::cloud::spanner::DmlResult Class Reference

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

#include <google/cloud/spanner/results.h>

Public Member Functions

 DmlResult ()=default
 
 DmlResult (std::unique_ptr< ResultSourceInterface > source)
 
 DmlResult (DmlResult &&)=default
 
DmlResultoperator= (DmlResult &&)=default
 
std::int64_t RowsModified () const
 Returns the number of rows modified by the DML statement. More...
 

Detailed Description

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.

Note
ExecuteDmlResult returns the number of rows modified.
Example:
using ::google::cloud::StatusOr;
namespace spanner = ::google::cloud::spanner;
std::int64_t rows_inserted;
auto commit_result = client.Commit(
[&client, &rows_inserted](
auto insert = client.ExecuteDml(
std::move(txn),
"INSERT INTO Singers (SingerId, FirstName, LastName)"
" VALUES (10, 'Virginia', 'Watson')"));
if (!insert) return std::move(insert).status();
rows_inserted = insert->RowsModified();
});
if (!commit_result) throw std::move(commit_result).status();
std::cout << "Rows inserted: " << rows_inserted;
Represents a potentially parameterized SQL statement.
Definition: sql_statement.h:51
The representation of a Cloud Spanner transaction.
Definition: transaction.h:58
std::vector< Mutation > Mutations
An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() muta...
Definition: mutations.h:99

Constructor & Destructor Documentation

◆ DmlResult() [1/3]

google::cloud::spanner::DmlResult::DmlResult ( )
default

◆ DmlResult() [2/3]

google::cloud::spanner::DmlResult::DmlResult ( std::unique_ptr< ResultSourceInterface source)
inlineexplicit

◆ DmlResult() [3/3]

google::cloud::spanner::DmlResult::DmlResult ( DmlResult &&  )
default

Member Function Documentation

◆ operator=()

DmlResult & google::cloud::spanner::DmlResult::operator= ( DmlResult &&  )
default

◆ RowsModified()

std::int64_t google::cloud::spanner::DmlResult::RowsModified ( ) const

Returns the number of rows modified by the DML statement.

Note
Partitioned DML only provides a lower bound of the rows modified, all other DML statements provide an exact count.