Is a statement like
SELECT Name FROM Persons WHERE Name LIKE ?1 LIMIT ?2
possible in SQLite3? For ?1
I can bind a parameter after the statement is prepared, using https://www.sqlite.org/c3ref/bind_blob.html. But is this also possible for ?2
? I could not get it to work and now I fear that I have to create a prepare a separate statement for each value of LIMIT, say 1, 10, 100, 1000, etc.
The answer is yes. It works for ?2 the same way as for ?1.
int iReturn = sqlite3_bind_text(pStmt, index, acValue, -1, SQLITE_TRANSIENT);
For limit, index
is 2 and acValue is a string which evaluates to an integer. I recommend setting SQLITE_TRANSIENT so that SQLite makes a copy of acValue. Otherwise one has to ensure that acValue does not go out of scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With