Skip to content

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

@Poyeyo

Description

@Poyeyo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions