Execute an SQL
select
statement.For an overview see page McoSqlEngine
Prototypes
ResultSet* SqlEngine::executeQuery(char const* sql, ...); ResultSet* SqlEngine::executeQuery(Transaction* trans, char const* sql, ...)Arguments
trans A Transaction instance. When passed, no implicit database transaction is started or committed. When absent, the SQL select
statement is executed within an implicit database transaction.sql A string containing an SQL select
statement with possible parameters to be substituted from the variable list... A variable length list of parameters to be substituted into the sql
stringDescription
These methods execute an SQL
select
statement 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 thetrans
parameter) 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.Returns
This method returns a QueryResult or throws a RuntimeException in the case of an error.
Example
const char * dbname = "SqlDb"; 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 ... QueryResult result(engine.executeQuery("select * from Person order by age")); ... }