# executeStatement

> Execute an SQL `insert`, `update` or `delete` statement 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 `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` string

> ### Description

> 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 of `executeQuery()` starts an implicit read-only database transaction and rolls back the transaction when finished. When the second version of `executeQuery()`, (with the `trans` 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. Multiple `INSERT`s 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");
>             ...
>         }