[code]Var absid as Integer, mystr, sql as String, reg as RowSet, dbh as SQLiteDatabase
absid = 25
mystr = “some text”
[/code]
and without using a prepared statement I might do this:
sql = "select * from mytable where id1=" + absid.ToString + " and dbstr='" + mystr + "' and id=" + absid.ToString
reg = db.SelectSQL (sql)
Note the use of absid in two places. Now, in recasting this to use the prepared statement facility built into the API2 database methods, can I do the following:
sql = "select * from mytable where id1=?1 and dbstr=?2 and id=?1"
reg = db.SelectSQL (sql, absid, mystr)
That is, only pass a variable in once, but refer to it more than once in the sql.
I assume this is with PostgreSQL? I suppose it works because the PostgreSQL driver uses numbered parameters, whereas the others don’t so you’d have to repeat the parameters in those.
[quote=489437:@Jay Madren]Sorry, missed that as well as Markus’ response.
Interesting. This is not indicated in the docs. I wonder if it’s a “bug” that may change in the future?[/quote]
No. I checked on the SQLite User Forum and Richard Hipp himself (author & lead developer of SQLite) said it was intended behaviour. So, not only can one do it but we won’t find that the ability suddenly vanishes.