Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-12-13 Thread Wout Mertens
On Fri, Nov 30, 2018 at 3:15 PM Dominique Devienne wrote: > sqlite> .header on > sqlite> create table t (c, n); > sqlite> insert into t values (1, 'one'), (2, 'two'), (3, 'three'); > sqlite> select n from t where c in (select value from json_each('[1, 3]')); > n > one > three Very nice! Now I

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-12-05 Thread James K. Lowden
On Fri, 30 Nov 2018 23:25:48 +0900 Simon Walter wrote: > > SELECT id, data FROM val WHERE id IN ("1, 893, 121212"); ... > I have no idea yet if MySQL and/or PostgreSQL can handle this > scenario and how they do it. The important thing to understand about parameterized queries is that they are

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Dominique Devienne
On Fri, Nov 30, 2018 at 3:26 PM Simon Walter wrote: > On 11/30/2018 11:20 PM, Dominique Devienne wrote: > To be honest, I am using apr_dbd as I would like to support more than > just SQLite. So I will need to play around with MySQL and PostgreSQL at > least and maybe branch if SQLite is in use.

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Simon Walter
On 11/30/2018 11:20 PM, Dominique Devienne wrote: > On Fri, Nov 30, 2018 at 3:03 PM Dominique Devienne > wrote: > >> On Fri, Nov 30, 2018 at 2:44 PM Richard Hipp wrote: >> >>> On 11/30/18, Simon Walter wrote: Thanks Dominique, Much appreciated. I can now stop pulling out my

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread R Smith
On 2018/11/30 2:52 PM, Simon Walter wrote: I am trying to make a prepared statement that has a parameter such as "1, 893, 121212". obviously it is text (a string) but it cannot be quoted or the result will be: SELECT id, data FROM val WHERE id IN ("1, 893, 121212"); I understand normally I

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Dominique Devienne
On Fri, Nov 30, 2018 at 3:03 PM Dominique Devienne wrote: > On Fri, Nov 30, 2018 at 2:44 PM Richard Hipp wrote: > >> On 11/30/18, Simon Walter wrote: >> > Thanks Dominique, >> > >> > Much appreciated. I can now stop pulling out my hair. I will do >> > something with sprintf. >> >> See

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Dominique Devienne
On Fri, Nov 30, 2018 at 2:44 PM Richard Hipp wrote: > On 11/30/18, Simon Walter wrote: > > Thanks Dominique, > > > > Much appreciated. I can now stop pulling out my hair. I will do > > something with sprintf. > > See https://www.sqlite.org/carray.html Right. Any table-valued function would do

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Richard Hipp
On 11/30/18, Simon Walter wrote: > Thanks Dominique, > > Much appreciated. I can now stop pulling out my hair. I will do > something with sprintf. See https://www.sqlite.org/carray.html Or, failing that, at least use sqlite3_mprintf() rather than sprintf(). https://www.sqlite.org/printf.html

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Simon Walter
Thanks Dominique, Much appreciated. I can now stop pulling out my hair. I will do something with sprintf. Best regards, Simon On 11/30/2018 10:37 PM, Dominique Devienne wrote: > On Fri, Nov 30, 2018 at 2:10 PM Simon Walter wrote: > >> How does one use WHERE x IN (?) with a prepared

Re: [sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Dominique Devienne
On Fri, Nov 30, 2018 at 2:10 PM Simon Walter wrote: > How does one use WHERE x IN (?) with a prepared statement? What is the > correct way to do this? > You cannot do it. Must use WHERE x IN (?, ?, ?), i.e. an explicit and known in advance number of bind placeholders. Or not use binding at

[sqlite] sqlite3_bind_text() and WHERE x IN (?)

2018-11-30 Thread Simon Walter
I am trying to make a prepared statement that has a parameter such as "1, 893, 121212". obviously it is text (a string) but it cannot be quoted or the result will be: SELECT id, data FROM val WHERE id IN ("1, 893, 121212"); I understand normally I would need the quotes, such as: SELECT id, name,