Re: [sqlite] Parameterized queries -- howto?
On Thu, October 21, 2004 7:51, Clay Dowling said: > Ron, > > Take a look at the example application in the Linux Journal article > http://www.linuxjournal.com/article.php?sid=7803 > > The parameterized queries provide a much better solution than sprintf. > You can grab a complete working app from the link at the end of the > article. > Thanks. I spent some time last night playing around with adding support for the parameterized queries to my C++ wrapper (around SQLite). It works nicely, thanks! -- My GPG public key is at http://ronware.org/ fingerprint: 8130 734C 69A3 6542 0853 CB42 3ECF 9259 AD29 415D
Re: [sqlite] Parameterized queries -- howto?
Ron, Take a look at the example application in the Linux Journal article http://www.linuxjournal.com/article.php?sid=7803 The parameterized queries provide a much better solution than sprintf. You can grab a complete working app from the link at the end of the article. Clay Dowling Ron Aaron said: > Anyway, in my particular case I have several similar queries which differ > only > in a few specifics. Right now I sprintf() to a temp buffer and execute > that > buffer -- but I was hoping that I could use sqlite's dialect of SQL more > directly rather than cobbling together my query piecemeal. > > It doesn't matter a whole lot, as the sprintf() or equivalent would have > to be > done somewhere. But it makes my application much more messy looking and > bigger than it would otherwise have to be. -- Lazarus Notes from Lazarus Internet Development http://www.lazarusid.com/notes/ Articles, Reviews and Commentary on web development
Re: [sqlite] Parameterized queries -- howto?
On Wed, October 20, 2004 18:05, Vladimir Vukicevic said: > I'm confused -- it doesn't make them useless in practice, they can be > used exactly for what they're intended for (precompiled statements). > What exactly are you trying to do? And what other database supports > this? I misspoke. They're not *useless*, but useless *within SQL*. I don't know about specific implemenations, but my copy of "A Guide to the SQL Standard, fourth edition" gives examples like: SQLSOURCE = 'DELETE FROM SP WHERE SP.QTY > ? and SP.QTY < ?'; EXEC SQL PREPARE SQLPREPPED FROM :SQLSOURCE ; LOW = 100; HIGH = 200; EXEC SQL EXECUTE SQLPREPPED USING :LOW , :HIGH ; We don't have any of these -- neither assignable SQL variables, nor an PREPARE or EXECUTE statement (if we had stored procedures we would need them). Anyway, in my particular case I have several similar queries which differ only in a few specifics. Right now I sprintf() to a temp buffer and execute that buffer -- but I was hoping that I could use sqlite's dialect of SQL more directly rather than cobbling together my query piecemeal. It doesn't matter a whole lot, as the sprintf() or equivalent would have to be done somewhere. But it makes my application much more messy looking and bigger than it would otherwise have to be. -- My GPG public key is at http://ronware.org/ fingerprint: 8130 734C 69A3 6542 0853 CB42 3ECF 9259 AD29 415D
Re: [sqlite] Parameterized queries -- howto?
On Wed, 20 Oct 2004 17:19:47 -0700 (PDT), Ron Aaron <[EMAIL PROTECTED]> wrote: > On Wed, October 20, 2004 15:35, Vladimir Vukicevic said: > > No; there is no way to create a stored query only within sql; there's > > no place to actually store it. So using parameters doesn't really get > > you anywhere. > > That is what I thought. Too bad, it makes them useless in practice. I'm confused -- it doesn't make them useless in practice, they can be used exactly for what they're intended for (precompiled statements). What exactly are you trying to do? And what other database supports this? - Vlad
Re: [sqlite] Parameterized queries -- howto?
On Wed, October 20, 2004 15:35, Vladimir Vukicevic said: > On Wed, 20 Oct 2004 15:15:44 -0700 (PDT), Ron Aaron <[EMAIL PROTECTED]> wrote: >> Thanks. I know it can be done in the C API, that was not the question. The >> question was, can it be done *using SQL* ? > > No; there is no way to create a stored query only within sql; there's > no place to actually store it. So using parameters doesn't really get > you anywhere. That is what I thought. Too bad, it makes them useless in practice. -- My GPG public key is at http://ronware.org/ fingerprint: 8130 734C 69A3 6542 0853 CB42 3ECF 9259 AD29 415D
Re: [sqlite] Parameterized queries -- howto?
On Wed, 20 Oct 2004 15:15:44 -0700 (PDT), Ron Aaron <[EMAIL PROTECTED]> wrote: > Thanks. I know it can be done in the C API, that was not the question. The > question was, can it be done *using SQL* ? No; there is no way to create a stored query only within sql; there's no place to actually store it. So using parameters doesn't really get you anywhere. - Vlad
Re: [sqlite] Parameterized queries -- howto?
insert into tbl values(?,?,?); then bind the parameters On Wed, 20 Oct 2004 15:15:44 -0700 (PDT), Ron Aaron <[EMAIL PROTECTED]> wrote: > > > > On Wed, October 20, 2004 14:57, Kurt Welgehausen said: > >> Am I missing something? > > > > Yes. Go to , click on , and > > read the C/C++ API Reference. > > > Thanks. I know it can be done in the C API, that was not the question. The > question was, can it be done *using SQL* ? > > > > > -- > My GPG public key is at http://ronware.org/ > fingerprint: 8130 734C 69A3 6542 0853 CB42 3ECF 9259 AD29 415D > > -- Cory Nelson http://www.int64.org
Re: [sqlite] Parameterized queries -- howto?
On Wed, October 20, 2004 14:57, Kurt Welgehausen said: >> Am I missing something? > > Yes. Go to , click on , and > read the C/C++ API Reference. Thanks. I know it can be done in the C API, that was not the question. The question was, can it be done *using SQL* ? -- My GPG public key is at http://ronware.org/ fingerprint: 8130 734C 69A3 6542 0853 CB42 3ECF 9259 AD29 415D
Re: [sqlite] Parameterized queries -- howto?
> Am I missing something? Yes. Go to , click on , and read the C/C++ API Reference. Regards
[sqlite] Parameterized queries -- howto?
I don't see any way to use parameterized queries from SQLite's version of SQL. Am I missing something? -- My GPG public key is at http://ronware.org/ fingerprint: 8130 734C 69A3 6542 0853 CB42 3ECF 9259 AD29 415D