Angus March wrote: > John Elrick wrote: > >> Angus March wrote: >> >> >>> I'm trying to make a prepared statement and bind parameters to it, but >>> the documentation is very confusing. This is the statement I'm trying to >>> prepare: >>> UPDATE 'KEYS' SET 'IVAndKey'=:VVV WHERE "ItemID"=?NNN >>> Where IVAndKey is a BLOB and ItemID is an INTEGER and the primary key >>> for the table. I'm told that there is a syntax error near "NNN". >>> >>> >>> >> The page (http://sqlite.org/c3ref/bind_blob.html) reads: >> >> "In the SQL strings input to sqlite3_prepare_v2() and its variants, >> literals may be replaced by a parameter in one of these forms: >> >> * ? >> * ?NNN >> * :VVV >> * @VVV >> * $VVV " >> >> The documentation for NNN is three sentences below this and states that >> the NNN refers to a number such as: >> >> ?1 ?2 >> >> > > I don't see that anywhere on the page. An example might have made a > difference. >
"The second argument is the index of the SQL parameter to be set. The leftmost SQL parameter has an index of 1. When the same named SQL parameter is used more than once, second and subsequent occurrences have the same index as the first occurrence. The index for named parameters can be looked up using the sqlite3_bind_parameter_index() API if desired. The index for "?NNN" parameters is the value of NNN. The NNN value must be between 1 and the sqlite3_limit() parameter SQLITE_LIMIT_VARIABLE_NUMBER (default value: 999)." > >> I'm also unsure why you've added single and double quotes. Maybe: >> >> UPDATE KEYS SET IVAndKey=? WHERE ItemID = ? >> >> > > Well, I was using single quotes before, and it didn't like them in > things like the WHERE clause and SELECT clause, so I changed those ones > to double quotes. Although quotes can be used, they are not needed when the table and field names contain all valid characters. I simply saw no value in adding them, and they did seem to unnecessarily complicate the text. HTH John _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users