db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Umesh Wagle" <Umesh.Wa...@sos.sungard.com>
Subject Sybase LIKE clause underscore wildcard problem
Date Tue, 19 Sep 2006 12:49:20 GMT
Hello Torque Users/Developers,

 

Greetings!

 

I have a workable system with MySQL 4.1  as a database and using Torque
3.2. Everything works fine there. I am trying to port the system to a
Sybase 12.5 database.

In one of my module I have a query formed as shown below: 

 

 

SELECT  * FROM CSFieldRegistry 

 

WHERE CSFieldRegistry.Name LIKE 'CSCLIENT\_%' 

 

AND CSFieldRegistry.CustomField=1 

AND CSFieldRegistry.Active=1 

AND CSFieldRegistry.Editable=1 

AND CSFieldRegistry.CSFirmID=10000021

 

Please observe the LIKE clause in the above query. It works fine on
MySQL as MySQL knows that a backslash (\) is an escape sequence for the
underscore (_)

 

But the query fails on Sybase as Sybase expects the query in the
following form.

 

SELECT  * FROM CSFieldRegistry 

 

WHERE CSFieldRegistry.Name LIKE 'CSCLIENT\_%'  escape '\' 

 

AND CSFieldRegistry.CustomField=1 

AND CSFieldRegistry.Active=1 

AND CSFieldRegistry.Editable=1 

AND CSFieldRegistry.CSFirmID=10000021

 

Please observe the LIKE clause. It needs to suffix it with an escape '\'
keyword.

 

It becomes a little difficult to have a approach which will work on both
the databases. Sybase expects ESCAPE and MySQL works fine with a
backslash '\.'

Sybase will not treat '\' as a default escape sequence whereas MySQL
will.

 

It would be of great help if you could guide me with a
resolution/approach which will make the query work on both the databases
(MySQL and Sybase)

 

Thanks for your help.

 

Cheers,

Umesh

 

 

******************

Umesh Wagle * Module Lead * SunGard Offshore services (India), Meridian
Plaza,Sr.No. 108/8/1 + 2/1, S.B.  Road, Pune - 411053, India 

Direct Tel : +91-20-25606197  * Main Tel.: +91-20-25606000 *
Fax.:+91-20-25606222  * umesh.wagle@SOS.SunGard.com * www.sungard.com
<http://www.sungard.com/> 

 

CONFIDENTIALITY: This email (including any attachments) may contain
confidential, proprietary and privileged information, and unauthorized
disclosure or use is prohibited. If you received this email in error,
please notify the sender and delete this email from your system. Thank
you. 

*******************

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message