Execute an SQL
insert,updateordeletestatement with a variable list of parameters.For an overview see page McoSqlEngine
Prototypes
int64_t SqlEngine::executeStatement(char const* sql, ...); int64_t SqlEngine::executeStatement(Transaction* trans, char const* sql, ...)Arguments
trans A Transaction instance. When passed, no implicit database transaction is started or committed. When absent, the SQL selectstatement is executed within an implicit database transaction.sql A string containing an SQL selectstatement with possible parameters to be substituted from the variable list... A variable length list of parameters to be substituted into the sqlstringDescription
These methods execute an SQL
selectstatement with a variable list of parameters. (See page Parameter Substitution Format Specifiers). It returns a QueryResult containing the set of table rows that satisfy the query. The first version ofexecuteQuery()starts an implicit read-only database transaction and rolls back the transaction when finished. When the second version ofexecuteQuery(), (with thetransparameter) is called, the query is executed within the context of this Transaction; the calling application code is responsible for starting and committing or rolling back the Transaction. MultipleINSERTs can be optimized.Returns
These methods return an integer value indicating the number of table rows affected, or throw a RuntimeException in the case of an error.
Example
int main(int argc, char* argv[]) { McoSqlEngine engine; ... engine.open(db_name, // database name SqlDb_get_dictionary(), // database dictionary DATABASE_SIZE, // database size MEMORY_PAGE_SIZE, // page size MAP_ADDRESS); // mapping address for shared memory mode ... rc = engine.executeStatement("delete from Person where name=%s", "Thomas"); ... }