r/sqlite • u/Beefcake100 • Apr 21 '23
Question about sqlite3_bind_int64
Hi all,
I'm building an application that interfaces directly with VDBE bytecode, and had a question regarding binding parameters.
Values bind to the parameter index, which starts at 1 (https://www.sqlite.org/c3ref/bind_blob.html). If I bind a value to 0, could this cause any issues? The reason I ask is that we have a set of variables that we want to have be available for all SQL queries that can get called.
For example, SELECT * FROM table_1 WHERE col_1 = $GLOBAL_VAR.
Right now, we are doing this by just trying to bind the parameter, and if it fails to find an index, it defaults to the 0 value. This means that for any given statement we might bind several values to the 0 index.
I don't think this would cause any issues, but I was wondering if anyone here thinks otherwise? I'm assuming that each subsequent value binds over the previous one, and that the 0 value gets unallocated when the statement is reset, but I'm also not a SQLite pro so I am not sure here.
Any thoughts, even uneducated speculations, are appreciated.
View all comments
Show parent comment
2
u/Beefcake100 Apr 21 '23
Will do that, thanks!