Hello all,
I've been doing a lot of JDBC queries involving where clauses such as
varchar = '...'
and
varchar LIKE '...'
Where the ... contents are user-entered and escaped using an escape method
I wrote (since we do not seem to have a publically accessible one in the
JDBC drivers).
I have noticed that escapes on the = work as advertised (put a backslash in
front of special characters and the character loses special meaning) but in
LIKE expressions, a new level of escaping is required. For example:
\\_ - ILIKE for a _ without special meaning
\\% - ILIKE for a % without special meaning
\\\\ - ILIKE for a \ without special meaning (matches a literal backslash)
\' - ILIKE for a '
Whereas, in an = clause, one can use
_ - without escapes or as \_
% - same as _
\\ - for a single \
\' - for a single quote
Unfortunately, this discrepancy seems to require me to have two different
"escape" functions: one for = comparisons, and another for LIKE comparisons.
Why can't I simply use \\ and \% and \_ in LIKE just as in =?
Many thanks,
Doug