Google Cloud Spanner C++ Client
1.32.0
A C++ Client Library for Google Cloud Spanner
|
Represents a potentially parameterized SQL statement. More...
#include <google/cloud/spanner/sql_statement.h>
Public Types | |
using | ParamType = std::unordered_map< std::string, Value > |
Type alias for parameter collection. More... | |
Public Member Functions | |
SqlStatement ()=default | |
SqlStatement (std::string statement) | |
Constructs a SqlStatement without parameters. More... | |
SqlStatement (std::string statement, ParamType params) | |
Constructs a SqlStatement with specified parameters. More... | |
SqlStatement (SqlStatement const &)=default | |
Copy and move. More... | |
SqlStatement (SqlStatement &&)=default | |
SqlStatement & | operator= (SqlStatement const &)=default |
SqlStatement & | operator= (SqlStatement &&)=default |
std::string const & | sql () const |
Returns the SQL statement. More... | |
ParamType const & | params () const |
Returns the collection of parameters. More... | |
std::vector< std::string > | ParameterNames () const |
Returns the names of all the parameters. More... | |
google::cloud::StatusOr< Value > | GetParameter (std::string const ¶meter_name) const |
Returns the value of the requested parameter. More... | |
Friends | |
bool | operator== (SqlStatement const &a, SqlStatement const &b) |
bool | operator!= (SqlStatement const &a, SqlStatement const &b) |
std::ostream & | operator<< (std::ostream &os, SqlStatement const &stmt) |
Outputs a string representation of the given stmt to the given os . More... | |
Represents a potentially parameterized SQL statement.
Details on case sensitivity for SQL statements and string values can be found here: Case Sensitivity
SqlStatement
equality comparisons are case-sensitive.Parameter placeholders are specified by @<param name>
in the SQL string. Values for parameters are a collection of std::pair<std::string const, google::cloud:spanner::Value>
.
Definition at line 51 of file sql_statement.h.
using google::cloud::spanner::v1::SqlStatement::ParamType = std::unordered_map<std::string, Value> |
Type alias for parameter collection.
Definition at line 54 of file sql_statement.h.
|
default |
|
inlineexplicit |
Constructs a SqlStatement without parameters.
Definition at line 58 of file sql_statement.h.
|
inline |
Constructs a SqlStatement with specified parameters.
Definition at line 61 of file sql_statement.h.
|
default |
Copy and move.
|
default |
google::cloud::StatusOr< Value > google::cloud::spanner::v1::SqlStatement::GetParameter | ( | std::string const & | parameter_name | ) | const |
Returns the value of the requested parameter.
parameter_name | name of requested parameter. |
StatusCode::kNotFound
returned for invalid names. Definition at line 51 of file sql_statement.cc.
|
default |
|
default |
std::vector< std::string > google::cloud::spanner::v1::SqlStatement::ParameterNames | ( | ) | const |
Returns the names of all the parameters.
Definition at line 42 of file sql_statement.cc.
|
inline |
Returns the collection of parameters.
Definition at line 80 of file sql_statement.h.
|
inline |
Returns the SQL statement.
No parameter substitution is performed in the statement string.
Definition at line 74 of file sql_statement.h.
|
friend |
Definition at line 98 of file sql_statement.h.
|
friend |
Outputs a string representation of the given stmt
to the given os
.
Definition at line 60 of file sql_statement.cc.
|
friend |
Definition at line 95 of file sql_statement.h.