On 12/20/2012 1:27 PM, Larry Brasfield wrote:
With recent versions of SQLite, a prepare call fails when there are parameters in the SQL for a 'create view' statement.
Did it ever work with any version of SQLite? Parameters in DDL statements don't make sense.
I stumbled into this for two reasons: The documentation for parameters and ..._prepare does not contra-indicate such usage; it seemed perfectly sensible; and it was useful in my application. (I have a complex view setup which I had wanted to vary, parametrically, when the view was queried.)
By what mechanism did you plan to feed parameter values into the view while SELECTing against it? What would the (hypothetical) syntax be like for such a beast?
Would there be any downside to allowing named parameters to remain in a view's SQL?
Ah, I think I see what you have in mind. If you do "select * from MyView", this query, even though it doesn't on the face of it appear to contain any placeholders, would be deemed to sort of incorporate by reference parameter placeholders from MyView.
Specifying such a feature would sure be fun. Say, if I select against two views that each have parameter named :X, should the query be considered to have one parameter (so that a single bound value applies to both views), or two (and then how would you refer to them?) What to do with a parameter like ?1 - where do you start counting?
I am tempted to offer a paragraph with which to enhance the doc page on parameters, explaining where they are allowed and where not. But I can only guess what it should say without a lot of experimentation or study of the code.
I believe it's pretty simple. Parameters are allowed everywhere a literal may appear, except in schema definition statements, namely various CREATE statements as well as ALTER TABLE; and also PRAGMA (not sure why). Currently, this leaves SELECT, INSERT, UPDATE, DELETE, REPLACE, ATTACH (the file name is an expression which allows parameters) and EXPLAIN (when the query being explained itself allows parameters). None of the remaining statements allow for literals in their syntax, so the issue is moot for them.
-- Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

