Skip to content

Commit

Permalink
Fix documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Apr 1, 2019
1 parent 50dab03 commit f77473b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions doc/General.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ A prepared statement can also be removed with a call to `c->deallocate( name )`.
## Results
The return value of `execute()` is of type `tao::pq::result`.
This class can be used in one of two ways, depending on whether the kind of SQL statement it is a result of.
For a `SELECT` statement the result will contain the result set and its description.
For `UPDATE`, `INSERT`, `DELETE` and other statements that operate on rows the result will contain the number of affected rows.
All other statements like `CREATE TABLE` will behave like a statement that affected zero rows.
The number of affected rows can be queried as follows.
For statements like `SELECT` or `UPDATE` the result can be used to query the number of affected or returned rows.
A complete list of statements for which this number is available can be found in the [PostgreSQL documentation](https://www.postgresql.org/docs/11/libpq-exec.html), see `PQcmdTuples()`.
```c++
const auto r2 = tr->execute( "DeleteUser", 42 );
assert( r2.has_affected_rows() );
std::cout << r2.affected_rows() << std::endl;
```

For all other statements, nothing useful can be done with the result.

For `SELECT` statements the result also contains the data returned by the query, the result set, and its description.

Working with a result set is documented on the [Result Sets](Result-Sets.md) page.

Note that `tao::pq::result` has value semantics and is relatively cheap to copy.
Expand Down

0 comments on commit f77473b

Please sign in to comment.