Add convenience methods `bind(String name, [types] value)` to SQLiteStatement class
Issue #53
resolved
Originally reported on Google Code with ID 53
To make code for binding named parameters to prepared SQLiteStatements simpler it'd be nice to have methods that lookup the index for you if you pass a string instead of an int to the first argument of bind(). For example, instead of needing things similar to: SQLiteStatement st = db.prepare("SELECT * FROM a WHERE col1 = :val1 AND col2 = :val2"); int i = st.getBindParameterIndex(":val1"); st.bind(i,"abc"); //finding index beforehand st.bind(st.getBindParameterIndex(":val2"),"xyz"); //compacted The code would look like: SQLiteStatement st = db.prepare("SELECT * FROM a WHERE col1 = :val1 AND col2 = :val2"); st.bind(":val1","abc"); st.bind(":val2","xyz"); The code for the additional methods would be really simple and quick to add. Just need to add something like: public SQLiteStatement bind(String name, String value) throws SQLiteException { bind(st.getBindParameterIndex(name),value); } For each value type that can be binded (double, int, long, String, etc).
Reported by ymangolds@c-2iinc.com
on 2013-04-01 22:55:25
Comments (3)
-
Account Deleted -
Thanks for the suggestion!
Reported by
sereda
on 2013-04-02 08:37:08 - Status changed:Accepted
- Labels added: Type-Enhancement - Labels removed: Type-Defect -
Account Deleted Reported by
linkogenerator
on 2013-08-22 20:09:42 - Status changed:Fixed
- Log in to comment
Reported by
ymangolds@c-2iinc.com
on 2013-04-01 23:00:10