Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use prepared statement in query() #17

Open
Poyeyo opened this issue May 19, 2022 · 1 comment
Open

Can't use prepared statement in query() #17

Poyeyo opened this issue May 19, 2022 · 1 comment

Comments

@Poyeyo
Copy link

Poyeyo commented May 19, 2022

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.
	});
@znone
Copy link
Owner

znone commented Jun 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants