Quotation marks and escape characters
An escape character indicates to the preprocessor that it should print the character as a literal character instead of interpreting it. You can use the escape character with an interpreted character to make the compiler escape, or ignore, the interpreted meaning.
\abc
,
the WHERE clause must use an escape character as follows:... where col1 = '\\abc';
... where col1 = '\'';
- You can use the same quotation mark as an escape character, as
follows:
... where col1 = '''';
- You can use an alternative quotation mark. For example, to look
for a double quotation mark, you can enclose this double quotation
mark with quotation marks, as follows:
... where col1 = ' "';
For the WHERE clause in Escaped query string as it is processed, the preprocessor does not process a double quotation mark; it passes it on to the C compiler. When the C compiler receives the string ' " ' (double quotation mark enclosed with quotation marks), it interprets the first quotation mark as the start of a string and the double quotation mark as the end of a string. The compiler cannot match the quotation mark that remains and therefore generates an error.
EXEC SQL select col1 from tab1 where col1 = '\"';
"\"
(where
the double quotation marks are part of the string): EXEC SQL select col1 from tab1 where col1 = '\"\\\\\"';
Processor | After processing |
---|---|
ESQL/C preprocessor | '\"\\\\\"' |
C compiler | '"\\"' |
ANSI-compliant database server | '"\"' |
supports strings in either quotation marks ('string') or double quotation marks ("string"). However, the C language supports strings only in double quotation marks. Therefore, the preprocessor converts every statement in the source file into a double-quoted string.