Re: [sqlite] Like and percent character

2014-07-03 Thread RSmith


On 2014/07/03 17:58, Micka wrote:

Sorry every one ! It's my fault !

I made a function on top of sqlite3_exec which have :

va_start(argp,acSql);
vasprintf(&acBuffSql, acSql, argp);

So this one tried to identify the %A  .


my bad ^^


All good :)

This is why I was asking for your code in an earlier post, because it often happens that some other function interjects at some 
point. So for your next question - and to the benefit of those in the audience who may have next questions - With great frequency on 
this list we get:


"Why is SQLite/sqlite3.exe doing xxx and in my program it does yyy???"

which then turns out to be a long to-and-fro of "did you check zzz?" or "try www and see what happens" until at some point a eureka 
occurs which results in "Oh no I was doing this seemingly un-related thing uuu which caused the yyy, fixed now - my bad!".


It's always a learning experience and I would propose that all learning is valuable. It is hard to fathom a type of code or use that 
/none/ of the programmers on this list ever encountered before, so with the next question, try to post as thorrough as possible with 
code and the like, it helps remarkably much and we'll be delighted to help figure it out.


Have a great day!
Ryan

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Like and percent character

2014-07-03 Thread Simon Slavin

On 3 Jul 2014, at 4:58pm, Micka  wrote:

> my bad ^^

No problem.  Glad you figured it out.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Like and percent character

2014-07-03 Thread Micka
Sorry every one ! It's my fault !

I made a function on top of sqlite3_exec which have :

va_start(argp,acSql);
vasprintf(&acBuffSql, acSql, argp);

So this one tried to identify the %A  .


my bad ^^




On Thu, Jul 3, 2014 at 5:40 PM, Simon Slavin  wrote:

>
> > On 3 Jul 2014, at 2:38pm, RSmith  wrote:
> >
> >
> > On 2014/07/03 15:12, Micka wrote:
> >> It's really weird that :
> >>
> >> SELECT * FROM names where name LIKE '%mic%'
> >>
> >> works with the sqlite3 command shell but not with the C librairie ..
>
> It works fine with the C library.  I'm betting that you are using a C
> function to assemble the string, and your C function understands '%' as a
> formatting or escape character.
>
> Try writing code to put the string
>
> SELECT * FROM names where name LIKE '%mic%'
>
> together then print the length of the string.  It should be 43 characters
> long.
>
> Simon.
> ___
> 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] Like and percent character

2014-07-03 Thread Simon Slavin

> On 3 Jul 2014, at 2:38pm, RSmith  wrote:
> 
> 
> On 2014/07/03 15:12, Micka wrote:
>> It's really weird that :
>> 
>> SELECT * FROM names where name LIKE '%mic%'
>> 
>> works with the sqlite3 command shell but not with the C librairie ..

It works fine with the C library.  I'm betting that you are using a C function 
to assemble the string, and your C function understands '%' as a formatting or 
escape character.

Try writing code to put the string

SELECT * FROM names where name LIKE '%mic%'

together then print the length of the string.  It should be 43 characters long.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Like and percent character

2014-07-03 Thread RSmith


On 2014/07/03 15:12, Micka wrote:

It's really weird that :

SELECT * FROM names where name LIKE '%mic%'

works with the sqlite3 command shell but not with the C librairie ..



Really?

So if you simply make the string  testSQL = "SELECT * FROM names WHERE name LIKE 
'%mic%';"
and pass it to your SQSLite C interface, then it returns (or not) different results to the same db being connected in the same way 
via the sqlite3.exe???


If that is the case then you are using the worst C library in history and should change it immediately - but I think the C library 
is fine and you are missing something obvious. It's hard to guess what since your descriptions are frustratingly scant - maybe post 
the actual complete C code for at least the full function where the error happens?


Also, check that you are referring the exact same DB file, what do other queries return when you add stuff via the command line 
function and then refer them in the C version? Sometimes Windows will make your app refer to a file that it duplicated to another 
place (via the UAC) when it is in a protected folder (such as "Program Files") and do not have a trustable manifest.


There are sometimes slight differences in how C libraries handle certain eventualities viz. the command-line interface, but SQL is a 
form of Algebra really and the truth of the returned answer can never be compromised.


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Like and percent character

2014-07-03 Thread Micka
It's really weird that :

SELECT * FROM names where name LIKE '%mic%'

works with the sqlite3 command shell but not with the C librairie ..



On Thu, Jul 3, 2014 at 2:19 PM, Micka  wrote:

> Well,
>
> I would love that to be simple . but when I printf my query, I got :
>
> SELECT * FROM names where name LIKE '%mic%'
>
> that the code :
> sprintf( acQuery, "SELECT * FROM names where name  LIKE '%%%s%%'  ",
> acName);
>
>
> So what could it be ? any ideas ?
>
>
> On Tue, Jun 3, 2014 at 4:21 PM, Hick Gunter  wrote:
>
>> Probably you are using a variant of the printf() function to generate
>> your statement and it is interpreting the %m as strerror(errno)  (see man 3
>> printf), whereas it is ignoring %' (thousands separator for decimal
>> conversions) either because it does not support this conversion or it is
>> missing the conversion specifier.
>>
>> Try inserting (3,'icka') into your table.
>>
>> If it works in the shell but not in your program, then it is nearly
>> always your program that is to blame.
>>
>> -Ursprüngliche Nachricht-
>> Von: Micka [mailto:mickamus...@gmail.com]
>> Gesendet: Dienstag, 03. Juni 2014 08:58
>> An: sqlite-users@sqlite.org
>> Betreff: [sqlite] Like and percent character
>>
>> Hi,
>>
>> I'm having trouble with the percent character .
>>
>>
>> By example in my table I have :
>>
>> id name
>> 1 micka
>> 2 mickael
>>
>> I would like to do that :
>>
>> Select * from table name where name LIKE '%micka%'
>>
>> with my linux c program, the result is 0
>>
>> but with the sqlite3 command program it works 
>>
>> I also tested this :
>>
>> Select * from table name where name LIKE 'micka%'
>>
>> and this time, it works in my linux c program ...
>>
>> I'm using the last package of sqlite3-dev ...
>> https://packages.debian.org/wheezy/sqlite3
>>
>> Why ?
>>
>> Thx you !
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>> ---
>> Gunter Hick
>> Software Engineer
>>
>> Scientific Games International GmbH
>> Klitschgasse 2 – 4, A - 1130 Vienna,
>> Austria
>> FN 157284 a, HG Wien
>> Tel: +43 1 80100 0
>> E-Mail: h...@scigames.at
>>
>> This e-mail is confidential and may well also be legally privileged. If
>> you have received it in error, you are on notice as to its status and
>> accordingly please notify us immediately by reply e-mail and then
>> delete this message from your system. Please do not copy it or use it for
>> any purposes, or disclose its contents to any person as to do so could be a
>> breach of confidence. Thank you for your cooperation.
>> ___
>> 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] Like and percent character

2014-07-03 Thread Micka
Well,

I would love that to be simple . but when I printf my query, I got :

SELECT * FROM names where name LIKE '%mic%'

that the code :
sprintf( acQuery, "SELECT * FROM names where name  LIKE '%%%s%%'  ",
acName);


So what could it be ? any ideas ?


On Tue, Jun 3, 2014 at 4:21 PM, Hick Gunter  wrote:

> Probably you are using a variant of the printf() function to generate your
> statement and it is interpreting the %m as strerror(errno)  (see man 3
> printf), whereas it is ignoring %' (thousands separator for decimal
> conversions) either because it does not support this conversion or it is
> missing the conversion specifier.
>
> Try inserting (3,'icka') into your table.
>
> If it works in the shell but not in your program, then it is nearly always
> your program that is to blame.
>
> -Ursprüngliche Nachricht-
> Von: Micka [mailto:mickamus...@gmail.com]
> Gesendet: Dienstag, 03. Juni 2014 08:58
> An: sqlite-users@sqlite.org
> Betreff: [sqlite] Like and percent character
>
> Hi,
>
> I'm having trouble with the percent character .
>
>
> By example in my table I have :
>
> id name
> 1 micka
> 2 mickael
>
> I would like to do that :
>
> Select * from table name where name LIKE '%micka%'
>
> with my linux c program, the result is 0
>
> but with the sqlite3 command program it works 
>
> I also tested this :
>
> Select * from table name where name LIKE 'micka%'
>
> and this time, it works in my linux c program ...
>
> I'm using the last package of sqlite3-dev ...
> https://packages.debian.org/wheezy/sqlite3
>
> Why ?
>
> Thx you !
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
> ---
> Gunter Hick
> Software Engineer
>
> Scientific Games International GmbH
> Klitschgasse 2 – 4, A - 1130 Vienna,
> Austria
> FN 157284 a, HG Wien
> Tel: +43 1 80100 0
> E-Mail: h...@scigames.at
>
> This e-mail is confidential and may well also be legally privileged. If
> you have received it in error, you are on notice as to its status and
> accordingly please notify us immediately by reply e-mail and then
> delete this message from your system. Please do not copy it or use it for
> any purposes, or disclose its contents to any person as to do so could be a
> breach of confidence. Thank you for your cooperation.
> ___
> 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] Like and percent character

2014-06-03 Thread Kevin Martin
Are you forming your query with sprintf? It may be worth printing the query you 
are preparing, to make sure it says what you think it is.

Thanks,
Kev

Sent from my iPhone

> On 3 Jun 2014, at 14:53, Micka  wrote:
> 
> Hi,
> 
> I'm having trouble with the percent character .
> 
> 
> By example in my table I have :
> 
> id name
> 1 micka
> 2 mickael
> 
> I would like to do that :
> 
> Select * from table name where name LIKE '%micka%'
> 
> with my linux c program, the result is 0
> 
> but with the sqlite3 command program it works 
> 
> I also tested this :
> 
> Select * from table name where name LIKE 'micka%'
> 
> and this time, it works in my linux c program ...
> 
> Why ?
> ___
> 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] Like and percent character

2014-06-03 Thread Hick Gunter
Probably you are using a variant of the printf() function to generate your 
statement and it is interpreting the %m as strerror(errno)  (see man 3 printf), 
whereas it is ignoring %' (thousands separator for decimal conversions) either 
because it does not support this conversion or it is missing the conversion 
specifier.

Try inserting (3,'icka') into your table.

If it works in the shell but not in your program, then it is nearly always your 
program that is to blame.

-Ursprüngliche Nachricht-
Von: Micka [mailto:mickamus...@gmail.com]
Gesendet: Dienstag, 03. Juni 2014 08:58
An: sqlite-users@sqlite.org
Betreff: [sqlite] Like and percent character

Hi,

I'm having trouble with the percent character .


By example in my table I have :

id name
1 micka
2 mickael

I would like to do that :

Select * from table name where name LIKE '%micka%'

with my linux c program, the result is 0

but with the sqlite3 command program it works 

I also tested this :

Select * from table name where name LIKE 'micka%'

and this time, it works in my linux c program ...

I'm using the last package of sqlite3-dev ...
https://packages.debian.org/wheezy/sqlite3

Why ?

Thx you !
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


---
Gunter Hick
Software Engineer

Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna,
Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This e-mail is confidential and may well also be legally privileged. If you 
have received it in error, you are on notice as to its status and accordingly 
please notify us immediately by reply e-mail and then
delete this message from your system. Please do not copy it or use it for any 
purposes, or disclose its contents to any person as to do so could be a breach 
of confidence. Thank you for your cooperation.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users