Re: Escape character weirdness



Hi;

That all makes sense except I tried \_ and it didn't work. Am I
missing something?

thanks - dave


On Thu, 13 Apr 2006 20:15:32 -0700, "Angel Saenz-Badillos[MS]"
<angelsa@xxxxxxxxxxxxxxxxxxxx> wrote:

David,
There is a long story with this one, let me try to take a stab at it. First
of all the solution as you have discovered is to use the brackets for
escaping. The problem of course is that you can't return brackets from the
getSearchStringEscape method, they would be useless. There is one scenario
where it is necesary _and_ possible to work arround this limitation, and
that is in the metadata calls themselves. After scratching our heads at this
for a while this is what we came up with:

From the documentation:
http://msdn2.microsoft.com/en-US/library/ms378896(SQL.90).aspx

"This getSearchStringEscape method is specified by the getSearchStringEscape
method in the java.sql.DatabaseMetaData interface.

This method is used only for metadata pattern searches. It returns "\". A
string search pattern can escape wildcards ("%" and "_") and provide them as
literals by prepending a backslash. This translates "\%" to "[%]" and "\_"
to "[_]". "

Here is the problem. Sql Server uses brackets '[]' to escape. The JDBC spec
is very clear in requiring a single character to escape to be returned from
getSearchStringEscape (it would be useless for this method to return
brackets). The solution? like most drivers we are returning '\' as our
escape character, when you use this in your metadata methods to escape
wildcards we will do a single pass replacing all '\%' characters with '[%]'
to get this feature to work properly.

example: use the DatabaseMetaData.getColumns() to retrieve the columns'
information to a table. getColumns() uses search pattern. Wildcards
('_','%','[') wich must be masked. This is where you can use the
getSearchStringEscape method.

As always we are open to suggestions.
Thanks,


david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
.