Skip to main content
November 3, 2006
Question

Using Quotes in a Query

  • November 3, 2006
  • 2 replies
  • 501 views
I am running CF MX7 Enterprise, and using a Sybase driver as the datasource. I can run this query just fine:

select my_field from my_table
where my_key = '1234'

but I get an error when I replace the single quotes with double quotes (shift-quote on the keyboard), like this:

select my_field from my_table
where my_key = "1234"

If I switch to an ODBC socket either one will work. It's just the Sybase driver that throws the error. Does anyone have any expeience with this?
This topic has been closed for replies.

2 replies

Inspiring
November 5, 2006
gmtjr wrote:
> I am running CF MX7 Enterprise, and using a Sybase driver as the datasource. I
> can run this query just fine:
>
> select my_field from my_table
> where my_key = '1234'
>
> but I get an error when I replace the single quotes with double quotes
> (shift-quote on the keyboard), like this:
>
> select my_field from my_table
> where my_key = "1234"
>
> If I switch to an ODBC socket either one will work. It's just the Sybase
> driver that throws the error.

Every proper database server will throw an error because the SQL
standard says that you are not supposed to do that.


Convert your queries to use cfqueryparam to solve the problem.

Jochem

--
Jochem van Dieten
Adobe Community Expert for ColdFusion
Participating Frequently
November 3, 2006
Why would you want to use double qoutes? That would be very non-standard, at least with databases other than Sybase. Use single quotes.

Phil
November 3, 2006
Maybe it isn't standard, but we already have a fairly large site in which about 500 scripts have this problem. As I said, they work fine now (upgrading from non-enterprise, earlier versions where all the connections were ODBC sockets). I want to use the Sybase driver but I don't want to oversee converting 500 scripts!
November 4, 2006
I believe you can futz with the "quoted identifier" settings in Sybase to work around the problem.

Sounds like you might also want to investigate layered applications and modular code. ;-)