Re: [sqlite] Cannot get bind to work
Simon Davies wrote: > On 17 November 2010 15:27, Jay A. Kreibichwrote: > >> On Wed, Nov 17, 2010 at 10:20:22AM -0500, Chris Wolf scratched on the wall: >> >>> I am trying to familiarize myself with the lower-level routines for >>> queries, so started with the >>> example here: >>> >> >>> not working - error 25, range erorr: >>> >>> ./client test.sqlite "select * from emp where ename = '?'" fred >>> >> This is not a place-holder. This is a single-character >> string-literal that consists of a question mark. >> >> Lose the quotes. The quotes are part of the string-literal >> specification, not the value itself. They're not needed for >> place-holders. Consider this statement if you were binding >> a integer, or something other than a text value. >> >> -j >> >> > > Furthermore, in your binding, loop from 0 to argc-3 rather than argc > >for(j=0; j // for(j=0; j printf("%d: %s\n", j+1, argv[3+j]); > if((rc = sqlite3_bind_text(pStmt, j+1, argv[3+j], -1,SQLITE_TRANSIENT)) >!= SQLITE_OK) { >fprintf(stderr, "%d: SQL error: %d - %s\n", __LINE__, > rc,sqlite3_errmsg(db)); >exit(1); > } >} > > Thanks for that - I also fixed the fprintf(stderr...) where the __LINE__ args were in the wrong position. -Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Cannot get bind to work
Jay A. Kreibich wrote: > On Wed, Nov 17, 2010 at 10:20:22AM -0500, Chris Wolf scratched on the wall: > >> I am trying to familiarize myself with the lower-level routines for >> queries, so started with the >> example here: >> > > > >> not working - error 25, range erorr: >> >> ./client test.sqlite "select * from emp where ename = '?'" fred >> > > This is not a place-holder. This is a single-character > string-literal that consists of a question mark. > > Lose the quotes. The quotes are part of the string-literal > specification, not the value itself. They're not needed for > place-holders. Consider this statement if you were binding > a integer, or something other than a text value. > >-j > that solved it, thanks so much. -Chris ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Cannot get bind to work
On 17 November 2010 15:27, Jay A. Kreibichwrote: > On Wed, Nov 17, 2010 at 10:20:22AM -0500, Chris Wolf scratched on the wall: >> I am trying to familiarize myself with the lower-level routines for >> queries, so started with the >> example here: > > >> not working - error 25, range erorr: >> >> ./client test.sqlite "select * from emp where ename = '?'" fred > > This is not a place-holder. This is a single-character > string-literal that consists of a question mark. > > Lose the quotes. The quotes are part of the string-literal > specification, not the value itself. They're not needed for > place-holders. Consider this statement if you were binding > a integer, or something other than a text value. > > -j > Furthermore, in your binding, loop from 0 to argc-3 rather than argc for(j=0; j > -- > Jay A. Kreibich < J A Y @ K R E I B I.C H > > > "Intelligence is like underwear: it is important that you have it, > but showing it to the wrong people has the tendency to make them > feel uncomfortable." -- Angela Johnson Regards, Simon ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Cannot get bind to work
On Wed, Nov 17, 2010 at 10:20:22AM -0500, Chris Wolf scratched on the wall: > I am trying to familiarize myself with the lower-level routines for > queries, so started with the > example here: > not working - error 25, range erorr: > > ./client test.sqlite "select * from emp where ename = '?'" fred This is not a place-holder. This is a single-character string-literal that consists of a question mark. Lose the quotes. The quotes are part of the string-literal specification, not the value itself. They're not needed for place-holders. Consider this statement if you were binding a integer, or something other than a text value. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users