Re: [sqlite] Syntax Errors with various strings?

2006-07-05 Thread Gussimulator

Thanks Gerry,
My strings are normal filenames with their paths, so as you can see there 
arent many characters that would ruin my day, however you're right about the 
' char.


I'll make my own quote(); routine and then I'll compare with the SQLite one 
by doing a small benchmark, see whats best for my case. I guess mine will 
win since I'll be able to make a macro in ASM. Instead of a DLL call, etc. 
Just by having the proc call, we lose cycles.








- Original Message - 
From: "Gerry Snyder" <[EMAIL PROTECTED]>

To: <sqlite-users@sqlite.org>
Sent: Wednesday, July 05, 2006 5:13 PM
Subject: Re: [sqlite] Syntax Errors with various strings?



Gussimulator wrote:

Thanks Christian, I'll give it a shot later.
Just because using quotation marks (did a quick macro that adds them to 
my string) did the job, doesnt mean its a better solution than this one.


In particular, if your strings include the  '  character, you will need to 
double it (make it  ''  ) somehow, and the quote() function will take care 
of this, as well as enclosing the string in quotation marks.


Gerry 




Re: [sqlite] Syntax Errors with various strings?

2006-07-05 Thread Gerry Snyder

Gussimulator wrote:

Thanks Christian, I'll give it a shot later.
Just because using quotation marks (did a quick macro that adds them 
to my string) did the job, doesnt mean its a better solution than this 
one.


In particular, if your strings include the  '  character, you will need 
to double it (make it  ''  ) somehow, and the quote() function will take 
care of this, as well as enclosing the string in quotation marks.


Gerry


Re: [sqlite] Syntax Errors with various strings?

2006-07-05 Thread Gussimulator

Thanks Christian, I'll give it a shot later.
Just because using quotation marks (did a quick macro that adds them to my 
string) did the job, doesnt mean its a better solution than this one.





- Original Message - 
From: "Christian Nassau" <[EMAIL PROTECTED]>

To: <sqlite-users@sqlite.org>
Sent: Wednesday, July 05, 2006 7:18 AM
Subject: Re: [sqlite] Syntax Errors with various strings?



Have you tried using the quote() function?

From http://www.sqlite.org/lang_expr.html

quote(X) This routine returns a string which is the value of its
argument suitable for inclusion into another SQL statement. Strings are
surrounded by single-quotes with escapes on interior quotes as needed.
BLOBs are encoded as hexadecimal literals. The current implementation of
VACUUM uses this function. The function is also useful when writing
triggers to implement undo/redo functionality.


Gussimulator wrote:
Hi, When I have strings with "-", "!",  "\" or similar characters I get a 
syntax error.. Now, I thought this would happen with a few of this chars 
so I made 2 routines in my program, one that converts each of this chars 
into a flag string, which then, by the other routine can be reverted to 
the original characters to obtain the string in its original form, so I 
can later work with it by my side.


Now, I've found myself with syntax errors even on strings that didnt had 
any strange characters, So.. I'm wondering, what can I do to prevent 
this? Does SQLite provide a "format" routine or is there anything I can 
do to prevent the syntax errors... like this ones? (since my data wont 
get into the db if theres an error, of course, thats why Im concerned).


I'm really worried about this, hence I subscribed on the list (first 
message!).  I hope someone can help me out on this one, thanks.


And, Indeed.. I'm quite a newbie on SQL but, I never thought I'd find 
myself with this type of problem.






--
---
Christian Nassau
Software Developer
---
Swissrisk
Holzhausenstrasse 44,
60322 Frankfurt, Germany

tele: +49 69 50952-266
fax:  +49 69 50952-299

www.swissrisk.com
--- 




Re: [sqlite] Syntax Errors with various strings? & ...Ampersand

2006-07-05 Thread Gussimulator

Enclosing the strings with quotation marks did the job.
Thanks a lot.



- Original Message - 
From: "C.Peachment" <[EMAIL PROTECTED]>

To: <sqlite-users@sqlite.org>
Sent: Wednesday, July 05, 2006 6:39 AM
Subject: Re: [sqlite] Syntax Errors with various strings? & ...Ampersand



The solution I have adopted to both of these issues is to:

1. ensure all strings are enclosed by matching quotation marks, and

2. use the question mark substitution form of prepared statement
with subsequent bind of parameters. This can only be done from a
programming language and not the command line interface.


On Wed, 05 Jul 2006 10:44:31 +0200, Roger wrote:


I have a company name as follows:



Chemistry & chemicals



I have plenty of those in my database which come with ampersands, now
when i do a query i get nothing.



How best can i write the query using a string with an ampersand as part
of it.



I am developing in a PHP/SQlite environment.



On Wed, 5 Jul 2006 06:07:46 -0300, Gussimulator wrote:

Hi, When I have strings with "-", "!",  "\" or similar characters I get a 
syntax error.. Now, I thought this would happen with a few of this chars 
so I
made 2 routines in my program, one that converts each of this chars into a 
flag string, which then, by the other routine can be reverted to the
original characters to obtain the string in its original form, so I can 
later work with it by my side.


Now, I've found myself with syntax errors even on strings that didnt had 
any strange characters, So.. I'm wondering, what can I do to prevent this?
Does SQLite provide a "format" routine or is there anything I can do to 
prevent the syntax errors... like this ones? (since my data wont get into 
the

db if theres an error, of course, thats why Im concerned).

I'm really worried about this, hence I subscribed on the list (first 
message!).  I hope someone can help me out on this one, thanks.


And, Indeed.. I'm quite a newbie on SQL but, I never thought I'd find 
myself with this type of problem.











Re: [sqlite] Syntax Errors with various strings?

2006-07-05 Thread Dennis Cote

Gussimulator wrote:

Hi, When I have strings with "-", "!",  "\" or similar characters I get a 
syntax error.. Now, I thought this would happen with a few of this chars so I made 2 routines in my program, 
one that converts each of this chars into a flag string, which then, by the other routine can be reverted to 
the original characters to obtain the string in its original form, so I can later work with it by my side.

  
When do you get these syntax errors and how are the strings being passed 
to SQLite? Are you using the correct single quote character (i.e. the ' 
not the ") as a string delimiter?


Dennis Cote



Re: [sqlite] Syntax Errors with various strings?

2006-07-05 Thread Christian Nassau
Have you tried using the quote() function?

>From http://www.sqlite.org/lang_expr.html

quote(X)This routine returns a string which is the value of its
argument suitable for inclusion into another SQL statement. Strings are
surrounded by single-quotes with escapes on interior quotes as needed.
BLOBs are encoded as hexadecimal literals. The current implementation of
VACUUM uses this function. The function is also useful when writing
triggers to implement undo/redo functionality.


Gussimulator wrote:
> Hi, When I have strings with "-", "!",  "\" or similar characters I get a 
> syntax error.. Now, I thought this would happen with a few of this chars so I 
> made 2 routines in my program, one that converts each of this chars into a 
> flag string, which then, by the other routine can be reverted to the original 
> characters to obtain the string in its original form, so I can later work 
> with it by my side.
> 
> Now, I've found myself with syntax errors even on strings that didnt had any 
> strange characters, So.. I'm wondering, what can I do to prevent this? Does 
> SQLite provide a "format" routine or is there anything I can do to prevent 
> the syntax errors... like this ones? (since my data wont get into the db if 
> theres an error, of course, thats why Im concerned).
> 
> I'm really worried about this, hence I subscribed on the list (first 
> message!).  I hope someone can help me out on this one, thanks.
> 
> And, Indeed.. I'm quite a newbie on SQL but, I never thought I'd find myself 
> with this type of problem.
> 
> 


-- 
---
Christian Nassau
Software Developer
---
Swissrisk
Holzhausenstrasse 44,
60322 Frankfurt, Germany

tele: +49 69 50952-266
fax:  +49 69 50952-299

www.swissrisk.com
---


Re: [sqlite] Syntax Errors with various strings? & ...Ampersand

2006-07-05 Thread C.Peachment
The solution I have adopted to both of these issues is to:

1. ensure all strings are enclosed by matching quotation marks, and

2. use the question mark substitution form of prepared statement
with subsequent bind of parameters. This can only be done from a
programming language and not the command line interface.


On Wed, 05 Jul 2006 10:44:31 +0200, Roger wrote:

>I have a company name as follows:

>Chemistry & chemicals

>I have plenty of those in my database which come with ampersands, now
>when i do a query i get nothing.

>How best can i write the query using a string with an ampersand as part
>of it.

>I am developing in a PHP/SQlite environment.


On Wed, 5 Jul 2006 06:07:46 -0300, Gussimulator wrote:

>Hi, When I have strings with "-", "!",  "\" or similar characters I get a 
>syntax error.. Now, I thought this would happen with a few of this chars so I 
made 2 routines in my program, one that converts each of this chars into a flag 
string, which then, by the other routine can be reverted to the 
original characters to obtain the string in its original form, so I can later 
work with it by my side.

>Now, I've found myself with syntax errors even on strings that didnt had any 
>strange characters, So.. I'm wondering, what can I do to prevent this? 
Does SQLite provide a "format" routine or is there anything I can do to prevent 
the syntax errors... like this ones? (since my data wont get into the 
db if theres an error, of course, thats why Im concerned).

>I'm really worried about this, hence I subscribed on the list (first 
>message!).  I hope someone can help me out on this one, thanks.

>And, Indeed.. I'm quite a newbie on SQL but, I never thought I'd find myself 
>with this type of problem.








[sqlite] Syntax Errors with various strings?

2006-07-05 Thread Gussimulator
Hi, When I have strings with "-", "!",  "\" or similar characters I get a 
syntax error.. Now, I thought this would happen with a few of this chars so I 
made 2 routines in my program, one that converts each of this chars into a flag 
string, which then, by the other routine can be reverted to the original 
characters to obtain the string in its original form, so I can later work with 
it by my side.

Now, I've found myself with syntax errors even on strings that didnt had any 
strange characters, So.. I'm wondering, what can I do to prevent this? Does 
SQLite provide a "format" routine or is there anything I can do to prevent the 
syntax errors... like this ones? (since my data wont get into the db if theres 
an error, of course, thats why Im concerned).

I'm really worried about this, hence I subscribed on the list (first message!). 
 I hope someone can help me out on this one, thanks.

And, Indeed.. I'm quite a newbie on SQL but, I never thought I'd find myself 
with this type of problem.