Return value of insert statement.
What is the return value of an insert statement like the one on the wiki?
db.run(insert_into(tab).set(tab.gamma = true));
In the end it is connector-dependent, but the typical behavior is to return the id of the line inserted, e.g. as returned by sqlite3_last_insert_rowid().
So the error reporting is done via exceptions I suppose?
I have a problem with an sqlite3 db that is accessed from multiple processes and, after some time, the insert does not throw but nothing is inserted. I was wondering if an error occurred and I forgot to check it.
Yes, errors are reported as exceptions, see src/connection.cpp:
void execute_statement(detail::connection_handle& handle, detail::prepared_statement_handle_t& prepared)
{
auto rc = sqlite3_step(prepared.sqlite_statement);
switch (rc)
{
case SQLITE_OK:
case SQLITE_ROW: // might occur if execute is called with a select
case SQLITE_DONE:
return;
default:
std::cerr << "Sqlite3 debug: sqlite3_step return code: " << rc << std::endl;
throw sqlpp::exception("Sqlite3 error: Could not execute statement: " +
std::string(sqlite3_errmsg(handle.sqlite)));
}
Please report a bug for the sqlite connector in case you trace it there.
Happy bug hunting!
Cheers,
Roland