Android Question What is a "db escape character"

Mikelgiles

Active Member
Licensed 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.
 

Erel

Administrator
Staff member
Licensed 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.
 

Mikelgiles

Active Member
Licensed 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!
 

sorex

Expert
Licensed 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.
 
Top