Re: [sqlite] Param Binding Problem
Thanks to Dan and Dennis for the heads up, all works great now Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dennis Cote Sent: 12 March 2008 17:12 To: General Discussion of SQLite Database Subject: Re: [sqlite] Param Binding Problem Mike Marshall wrote: > > acQuery = sqlite3_mprintf("SELECT rowid FROM fulltext_%s WHERE contents > MATCH '? '",sTempTableRoot.c_str()); You need to remove he quotes around the ? following MATCH. With the quotes it is a literal string containing a question mark. Without them it is a parameter inthe query that you can bind some string value to later. > > nError from the prepare is SQLITE_OK but from the bind its SQLITE_RANGE > This is because you don't have any parameters to be bound. HTH Dennis Cote ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Param Binding Problem
Mike Marshall wrote: > > acQuery = sqlite3_mprintf("SELECT rowid FROM fulltext_%s WHERE contents > MATCH '? '",sTempTableRoot.c_str()); You need to remove he quotes around the ? following MATCH. With the quotes it is a literal string containing a question mark. Without them it is a parameter inthe query that you can bind some string value to later. > > nError from the prepare is SQLITE_OK but from the bind its SQLITE_RANGE > This is because you don't have any parameters to be bound. HTH Dennis Cote ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Param Binding Problem
On Mar 12, 2008, at 11:40 PM, Mike Marshall wrote: > Hi all > > > > I'm trying to get param binding working and I'm obviously doing > something > wrong > > > > My code is > > > > acQuery = sqlite3_mprintf("SELECT rowid FROM fulltext_%s WHERE > contents > MATCH '? '",sTempTableRoot.c_str()); Don't put quotes around the ? character. ('? ') is a literal string. You probably want (? || ' ') - an SQL variable with a single space appended to it. Dan. > > nError = sqlite3_prepare_v2(m_pHandle,acQuery,-1,,NULL); > > nError = > sqlite3_bind_text(pStatement,1,m_sQuery.c_str(),-1,SQLITE_TRANSIENT); > > > > nError from the prepare is SQLITE_OK but from the bind its > SQLITE_RANGE > > > > Anyone got any ideas where I'm going wrong, or is it the fact that I'm > trying to do a bind on a MATCH (fts) that is giving me the problem. > > > > Any and all help gratefully received > > > > Mike > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users