Re: [sqlite] Formatting SQLite-query
Maybe yes. I am currently looking into parameterized queries. Is it like this: sqlite_prepare sqlite_bind_* sqlite_finalize with the query like 'SELECT * FROM ? WHERE ? = ?'... But how can I know what I pass? I mean with %d/%s/... It's rather obvious, but how do I know what I pass when I use those parameters... And this project has been put aside for a while until I find a solution for this problem (it's the only thing keeping me from completing the program :p). But I have still other things to do ;-). Thanks for any help! At 21:35 1/11/2004, you wrote: Steven Van Ingelgem said: > > Sorry but this has already been suggested by "Tiago Dionizio". > > I can use this, but then I have to create some kind of own printf-function > which scans and so on and handles %q's (which is rather dumb in my > opinion, > as SQLite already incorporates it?). > > > I think this is a va_* error but I am unable to determine the exact > source... Your issue then is less with SQLite and more with C++ programming. Your error message might be showing up deep in the SQLite library, but the problem occurs in your handling of the parameters. I would advise you not to let your project get held up on the %Q issue, since the escaping you need to do is pretty trivial. Also consider that SQLite 3 allows you to use parameterized queries, which eliminates the need for the escaping anyway. -- Lazarus Notes from Lazarus Internet Development http://www.lazarusid.com/notes/ Articles, Reviews and Commentary on web development KaReL (aka Steven) Main Webpage : http://www.karels0ft.be/ ICQ # : 35217584 pgp6uvnhC8wCR.pgp Description: PGP signature
Re: [sqlite] Formatting SQLite-query
Steven Van Ingelgem said: > > Sorry but this has already been suggested by "Tiago Dionizio". > > I can use this, but then I have to create some kind of own printf-function > which scans and so on and handles %q's (which is rather dumb in my > opinion, > as SQLite already incorporates it?). > > > I think this is a va_* error but I am unable to determine the exact > source... Your issue then is less with SQLite and more with C++ programming. Your error message might be showing up deep in the SQLite library, but the problem occurs in your handling of the parameters. I would advise you not to let your project get held up on the %Q issue, since the escaping you need to do is pretty trivial. Also consider that SQLite 3 allows you to use parameterized queries, which eliminates the need for the escaping anyway. -- Lazarus Notes from Lazarus Internet Development http://www.lazarusid.com/notes/ Articles, Reviews and Commentary on web development
Re: [sqlite] Formatting SQLite-query
Sorry but this has already been suggested by "Tiago Dionizio". I can use this, but then I have to create some kind of own printf-function which scans and so on and handles %q's (which is rather dumb in my opinion, as SQLite already incorporates it?). I think this is a va_* error but I am unable to determine the exact source... At 20:07 1/11/2004, you wrote: Steven Van Ingelgem said: > Sorry to bump this up, but i was still not able to find an answer for > this > question :( > > http://www.wxwidgets.org/manuals/2.4.2/wx368.htm#wxstringformat Clay Dowling -- Lazarus Notes from Lazarus Internet Development http://www.lazarusid.com/notes/ Articles, Reviews and Commentary on web development KaReL (aka Steven) Main Webpage : http://www.karels0ft.be/ ICQ # : 35217584 pgpIki8qNIiOM.pgp Description: PGP signature
Re: [sqlite] Formatting SQLite-query
Steven Van Ingelgem said: > Sorry to bump this up, but i was still not able to find an answer for > this > question :( > > http://www.wxwidgets.org/manuals/2.4.2/wx368.htm#wxstringformat Clay Dowling -- Lazarus Notes from Lazarus Internet Development http://www.lazarusid.com/notes/ Articles, Reviews and Commentary on web development
Re: [sqlite] Formatting SQLite-query
Because wxString::Format doesn't have the '%q' functions which sqlite provides ;-) At 21:30 25/10/2004, you wrote: I assume you are using wxWidgets.. why don't you consider using the specific functions for that purpose included in the wxString class? wxString::Format and wxString::FormatV Tiago On Mon, 25 Oct 2004 20:43:31 +0200, Steven Van Ingelgem <[EMAIL PROTECTED]> wrote: > Hi, > > I wanted to create my own "Format"-thingie, based upon my own database: > > - > Source > - > wxString SQLite3_Db::Format( const wxString& format, ... ) > { > va_list marker; > va_start(marker, format); > > char * t = sqlite3_vmprintf( format.mb_str(wxConvUTF8).data(), marker ); > > va_end(marker); > > wxString retVal( t, wxConvUTF8 ); > > sqlite3_free( t ); > > return retVal; > } > - > > The problem here is that I get very weird results... Now tracing down, I > found that in vxprintf (printf.c) "v = va_arg(ap,int);" is done (my first > argument is %d). > > Now what he gets there is the second parameter! > > > To be more clear: > > SQLite3_Db::Format( "%d%s", 123, "Test" ); > > Then sqlite finds the first %d, tries to get the value of it, but finds the > pointer pointing to 'Test'... > > > > What did I do wrong? > Thx ;) > > > > > KaReL (aka Steven) > > Main Webpage : http://www.karels0ft.be/ > ICQ # : 35217584 > > KaReL (aka Steven) Main Webpage : http://www.karels0ft.be/ ICQ # : 35217584 pgpcrXoXZvKuj.pgp Description: PGP signature
Re: [sqlite] Formatting SQLite-query
I am using Visual C++ 6. And I am using the source-version 3.0.8 of SQLite. So the va_list/end/start... functions should all be the very same... That's why it got me puzzled :S At 22:24 25/10/2004, you wrote: Hi Steve, > Hi, > > I wanted to create my own "Format"-thingie, based upon my own database: [snip] > What did I do wrong? I am not sure, but if the compiler AND the implementation of va_list etc. weren't the same, then all bets are off. This is because va_list etc. are highly implementation-dependent, as the C standard AND the Kernighan & Ritchie book state explicitly. Are you using a precompiled version of SQLite? If so, you need to compile it yourself with the same compiler you are using for your app. If the compiler is the same, does the header file for the va_list etc. implementations come from C++, while the one in SQLite comes from the C library? Then you need to change the C++ code to use the same header file as SQLite. HTH Ulrik Petersen -- Ulrik Petersen, Denmark Emdros -- the text database engine for analyzed or annotated text http://emdros.org/ KaReL (aka Steven) Main Webpage : http://www.karels0ft.be/ ICQ # : 35217584 pgpxKdToRO1oW.pgp Description: PGP signature
Re: [sqlite] Formatting SQLite-query
I assume you are using wxWidgets.. why don't you consider using the specific functions for that purpose included in the wxString class? wxString::Format and wxString::FormatV Tiago On Mon, 25 Oct 2004 20:43:31 +0200, Steven Van Ingelgem <[EMAIL PROTECTED]> wrote: > Hi, > > I wanted to create my own "Format"-thingie, based upon my own database: > > - > Source > - > wxString SQLite3_Db::Format( const wxString& format, ... ) > { >va_list marker; >va_start(marker, format); > >char * t = sqlite3_vmprintf( format.mb_str(wxConvUTF8).data(), marker ); > >va_end(marker); > >wxString retVal( t, wxConvUTF8 ); > >sqlite3_free( t ); > >return retVal; > } > - > > The problem here is that I get very weird results... Now tracing down, I > found that in vxprintf (printf.c) "v = va_arg(ap,int);" is done (my first > argument is %d). > > Now what he gets there is the second parameter! > > > To be more clear: > > SQLite3_Db::Format( "%d%s", 123, "Test" ); > > Then sqlite finds the first %d, tries to get the value of it, but finds the > pointer pointing to 'Test'... > > > > What did I do wrong? > Thx ;) > > > > > KaReL (aka Steven) > > Main Webpage : http://www.karels0ft.be/ > ICQ #: 35217584 > >
[sqlite] Formatting SQLite-query
Hi, I wanted to create my own "Format"-thingie, based upon my own database: - Source - wxString SQLite3_Db::Format( const wxString& format, ... ) { va_list marker; va_start(marker, format); char * t = sqlite3_vmprintf( format.mb_str(wxConvUTF8).data(), marker ); va_end(marker); wxString retVal( t, wxConvUTF8 ); sqlite3_free( t ); return retVal; } - The problem here is that I get very weird results... Now tracing down, I found that in vxprintf (printf.c) "v = va_arg(ap,int);" is done (my first argument is %d). Now what he gets there is the second parameter! To be more clear: SQLite3_Db::Format( "%d%s", 123, "Test" ); Then sqlite finds the first %d, tries to get the value of it, but finds the pointer pointing to 'Test'... What did I do wrong? Thx ;) KaReL (aka Steven) Main Webpage : http://www.karels0ft.be/ ICQ # : 35217584 pgpXI8zwUXOqi.pgp Description: PGP signature