• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Preserving Single Quotes

Participant ,
Sep 27, 2006 Sep 27, 2006

Copy link to clipboard

Copied

I'm using the following code to produce a list of zipcodes for a radius search:
<cfset Caller.passedreturneddata = Caller.passedreturneddata & "'#mystruct.zipcode#' or ">
The result is like '12345' or '23456' or '34567'.

CF is turning the single quotes into double quotes and giving SQL error below. How can I preserve the single quotes?

Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression &apos;fee = No And Category = Horoscope And Subcategory = Horoscope3 And ZipCode = &apos;&apos;80212&apos;&apos; or &apos;&apos;80212&apos;&apos; or &apos;&apos;80212&apos;&apos; or &apos;&apos;80034&apos;&apos; or &apos;&apos;80214&apos;&apos; or &apos;&apos;80214&apos;&apos; or &apos;&apos;80214&apos;&apos; or &apos;&apos;80214&apos;&apos; or &apos;&apos;80211&apos;&apos; or &apos;&apos;80033&apos;&apos; or &apos;&apos;80033&apos;&apos; or &apos;&apos;80033&apos;&apos; or &apos;&apos;80001&apos;&apos; or &apos;&apos;80002&apos;&apos; or&apos;.

The error occurred in eventsradius.cfm: line 8

6 : And Category = #form.category#
7 : And Subcategory = #form.subcategory#
8 : And ZipCode = #form.zipcode#
9 : Order by date, time
10 : </cfquery>



--------------------------------------------------------------------------------

SQL Select * From Calendar2 Where fee = No And Category = Horoscope And Subcategory = Horoscope3 And ZipCode = ''80212'' or ''80212'' or ''80212'' or ''80034'' or ''80214'' or ''80214'' or ''80214'' or ''80214'' or ''80211'' or ''80033'' or ''80033'' or ''80033'' or ''80001'' or ''80002'' or ''80002'' or ''80002'' or ''80204'' or ''80295'' or ''80257'' or ''80266'' or ''80266'' or ''80248'' or ''80217'' or ''80265'' or ''80292'' or ''80215'' or ''80215'' or ''80215'' or ''80255'' or Order by date, time
DATASOURCE normmy_denver
VENDORERRORCODE -3100
SQLSTATE 42000



Thanks!
David
TOPICS
Advanced techniques

Views

772

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Sep 29, 2006 Sep 29, 2006
I got it to work with a variation of what you guys wrote...

And ZipCode IN (#PreserveSingleQuotes (passedreturneddata)#)

Thanks for all the help!
D.

Votes

Translate

Translate
Participant ,
Sep 27, 2006 Sep 27, 2006

Copy link to clipboard

Copied

Try something like this. #Replace(key,"'","&rsquo;")#

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 27, 2006 Sep 27, 2006

Copy link to clipboard

Copied

i think your error is due to a wrong sql statement first of all... you have to use ZipCode = before each value you are checking fo, not just once like you do.

so you have to change
<cfset Caller.passedreturneddata = Caller.passedreturneddata & "'#mystruct.zipcode#' or ">
to
<cfset Caller.passedreturneddata = Caller.passedreturneddata & "'#mystruct.zipcode#' or ZipCode=">

on the other hand, why don't you change your Caller.passedreturneddata to a comma-delimited list and then use "... AND ZipCode IN '#Caller.passedreturneddata#' instead?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 27, 2006 Sep 27, 2006

Copy link to clipboard

Copied

use the preservesinglequotes function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 27, 2006 Sep 27, 2006

Copy link to clipboard

Copied

Originally it was a comma delimited list, but frankly I wasn't sure how work with it that way. So if I understand you that would be...

<cfquery datasource="normmy_denver" name="events">
Select *
From Calendar2
Where fee = No
And Category = #form.category#
And Subcategory = #form.subcategory#
And ZipCode IN '#Caller.passedreturneddata#'
Order by date, time
<cfquery>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 28, 2006 Sep 28, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: InkFasT!
<cfquery datasource="normmy_denver" name="events">
Select *
From Calendar2
Where fee = No
And Category = #form.category#
And Subcategory = #form.subcategory#
And ZipCode IN '# ListQualify(Caller.passedreturneddata, "'")#'
Order by date, time
<cfquery>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 27, 2006 Sep 27, 2006

Copy link to clipboard

Copied

yes, as long as your Caller.passedreturneddata is a comma-delimited list, you can use it like that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 28, 2006 Sep 28, 2006

Copy link to clipboard

Copied

That worked for the single quotes, but I've never seen this error before. Not finding anything in Google either.

Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] In operator without () in query expression &apos;fee = No And Category = Horoscope And Subcategory = Horoscope3 And ZipCode IN

Select * From Calendar2 Where fee = No And Category = Horoscope And Subcategory = Horoscope3 And ZipCode IN ''80212',' 80212',' 80212',' 80034',' 80214',' 80214',' 80214',' 80214',' 80211',' 80033',' 80033',' 80033',' 80001',' 80002',' 80002',' 80002',' 80204',' 80295',' 80257',' 80266',' 80266',' 80248',' 80217',' 80265',' 80292',' 80215',' 80215',' 80215',' 80255',' '' Order by date, time

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006

Copy link to clipboard

Copied

You need parentheses when using the keyword IN in sql. It's right there in your error message, didn't you read it?

You should also know that you have changed your logic from what you were initially attempting to do.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 28, 2006 Sep 28, 2006

Copy link to clipboard

Copied

I read it, I didn't understand it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 29, 2006 Sep 29, 2006

Copy link to clipboard

Copied

LATEST
I got it to work with a variation of what you guys wrote...

And ZipCode IN (#PreserveSingleQuotes (passedreturneddata)#)

Thanks for all the help!
D.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation