Android Question What is a "db escape character"

Mikelgiles

Active Member
Licensed User
Longtime User
In reference to DBUTILS escapefield() I see a reference to "db escape character" and am wondering what a "db escape character" is for. I am a pretty new at SQL and have never used sqlite at all.
 

emexes

Expert
Licensed User
<TRIVIA> Here is a link about the original "db escape character" </TRIVIA>

upload_2019-9-19_0-13-48.png
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is important to watch the SQL video tutorial and use parameterized queries.

EscapeField is a private sub in DBUtils. Wrapping fields / columns names with square brackets allows using spaces inside the column names.
B4X:
"Select col1, col2, col3 FROM table1" 'good
"Select [col1], [col2], [col3] FROM table1" 'also good
"Select col 1, col2, col3 FROM table1" 'not good
"Select [col 1], [col2], [col3] FROM table1" 'good

I don't recommend using spaces or other characters that need to be escaped in the column names.
 
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
It is important to watch the SQL video tutorial and use parameterized queries.

EscapeField is a private sub in DBUtils. Wrapping fields / columns names with square brackets allows using spaces inside the column names.
B4X:
"Select col1, col2, col3 FROM table1" 'good
"Select [col1], [col2], [col3] FROM table1" 'also good
"Select col 1, col2, col3 FROM table1" 'not good
"Select [col 1], [col2], [col3] FROM table1" 'good

I don't recommend using spaces or other characters that need to be escaped in the column names.
So unless I want to include spaces in field names I dont need to use it? I have always assumed that spaces were a no-no and have never felt the need to use them. And thanks for the very quick response!
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
you can still use an underscore instead of space if you don't want a number to be close to the text part for readability.
 
Upvote 0
Top