-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
D. Richard Hipp wrote:
| Parameters can be in any of three forms: | | * <question-mark> | * <colon><identifier> | * <dollar-sign><tcl-variable-name> | | Each parameter is assigned a number. Numbers are sequential from left | to right and begin with 1. The parameter number is used to bind values | to the parameter. All parameters get a different number, even those | with identical names.
I vote for:
* <question-mark> * <question-mark><number> * <colon><identifier> * <dollar-sign><tcl-variable-name>
Only question mark parameters should get a number, one greater as the last used. The identifier and tcl variable name parameters shouldn't get a number. The rational behind this is:
There are two possible languages that use sqlite. The first group of language known nothing about names used for variables, e.g. 'C'. The second group known somehow the names of the variables used, e.g. TCL and Phyton I think.
So, in a language, where you don't have access to your variable names, you could write a function like:
bind(stmt, args) for i = 1 to number_of_items(args) do sqlite3_bind_xxx(stmt, args[i]) end end
You use this wrapper from your language like this:
bind(stmt1, "Hello World") bind(stmt2, id_variable, str_variable, "Some constant")
In language where you have access to the names of variables you could write a function like:
bind(stmt, args) for key, value in all_pairs(args) do sqlite3_bind_xxx(stmt, key, value) end end
You use this wrapper like this from your language:
bind(stmt1, name = "Hello World") bind(stmt2, id = id_var, str = str_var, foobar = "Hello") or: bind(stmt2, foobar = "Hello", id = id_var, str = str_var)
But if you omit the ?nnn syntax and count all parameters in the sql statement, is isn't nice to use sqlite from languange of the first example:
stmt = sqlite3_prepare("SELECT xxx WHERE x=:id and y=:id)
You don't know in these language that the first paramter :id is the same as the second paramter :id. And you can't use the variable names of the language itself, to bind the value. Instead you must do something like this:
bind_some_statement(stmt, id) sqlite3_bind_xxx(stmt, 1, id) sqlite3_bind_xxx(stmt, 2, id) end
bind_some_other(stmt, id, content) sqlite3_bind_xxx(stmt, 1, id) sqlite3_bind_xxx(stmt, 2, content) sqlite3_bind_xxx(stmt, 3, id) sqlite3_bind_xxx(stmt, 4, id) sqlite3_bind_xxx(stmt, 5, content) end
The point is, you can't write an nice and univeral wrapper. That's not a good thing, I think.
Michael Roth
-----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBLba1SIrOxc3jOmoRAhr9AKCg3GYPMx/ZOFvIcmmA4gjnhgYXAACfY138 DUasCesoCJufsgFHaGebQ7Y= =8IFs -----END PGP SIGNATURE-----