qtl
qtl copied to clipboard
Can't use prepared statement in query()
Something like this:
auto stmt=db.open_command(sql_query); // string sql_query created with code, possible different WHERE conditions
// different parameters added
if (opt_id != 0) {
stmt << opt_id;
stmt << opt_other;
} else {
stmt << opt_other;
}
// this should work
db.query(stmt,
[&](const string &field1, const string &field2, const uint64_t &field3) {
// the body of the lambda function is long and there's no need to repeat it.
});
This is a SQL problem, the parameters you provided must be the same as required in the SQL. QTL directly transparently transmits your parameters to the database.