On 5/4/2013 8:59 AM, Stephan Beal wrote:
The intuitive implication of sqlite3_bind_parameter_index()'s definition is that the bind-by-name operations are (or could/should be) implemented as proxies like: bind_by_name("name", value) ==> bind_by_index( index_of_name("name"), value ). (Whether or not it's actually implemented that way, i don't know - i have not delved into the sqlite sources here.)
There is no bind-by-name API in SQLite. You must explicitly call sqlite3_bind_parameter_index, then bind by index.
That breaks down, however, when duplicating parameter names.
Breaks down in what way? What are you trying to do, and failing?
This poses an "interesting problem" for me because my DB abstraction API only exposes bind-by-index and get-index-of-named-parameter APIs
Just like SQLite, then. What seems to be the problem?
The implication of that is that it becomes impossible for my API to support multiple instances of the same parameter name [without notable re-tooling and adding one additional bind-by-name method per bindable data type].
Why? It doesn't matter how many times a parameter is used. You bind a value to it once, and that value applies everywhere.
i'm curious if there is a way to get all of the indexes of a given named parameter?
When you say "index", you seem to mean "a particular occurrence of a parameter within the query". But sqlite3_bind_parameter_index, as well as sqlite3_bind_int et al, take an index within the flat list of all parameters, regardless of how often these parameters occur in the query, if at all. In your example, there are two occurrences of a parameter within the query, but only one actual parameter (sqlite3_bind_parameter_count would return 1), at index 1.
Consider this statement: "select ?5, ?10, ?5 + ?10". It has 10 parameters, indexed 1 through 10 (of which only two are actually used), which occur four times in the query.
For example, for the above SQL snippet i "would like to" be able to get the values (1, 2) in some manner.
What do you mean, get the values? There's only one parameter, to which you can bind one value.
-- Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users