qtl icon indicating copy to clipboard operation
qtl copied to clipboard

Can't use prepared statement in query()

Open Poyeyo opened this issue 2 years ago • 1 comments

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.
	});

Poyeyo avatar May 19 '22 15:05 Poyeyo

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.

znone avatar Jun 01 '22 08:06 znone