This will work:

<CFQUERY name="GetResults" dataSource="W**">
        SELECT *
          FROM Tasks
         WHERE Archive = 0
        #PreserveSingleQuotes(type_sql)#
</CFQUERY>

-------------------------------------
>From the docs:

PreserveSingleQuotes

Prevents ColdFusion from automatically "escaping" single quotes contained in
variable.

Syntax

PreserveSingleQuotes(variable)

variable

Variable containing the string for which single quotes are preserved.

Usage

PreserveSingleQuotes is useful in SQL statements.

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




-----Original Message-----
From: Eric Post [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 26, 2001 4:10 PM
To: CF-Talk
Subject: Weird delimiter problem with CFquery


Howdy,

I am trying to build a dynamic SQL IN statement and am
getting strange results.

This is the value of the string variable I send to my
CFquery:

#type_sql# = and typeofissue in ('Enchancement','Bug')

Here is my query:
<CFQUERY name="GetResults" dataSource="W**">
        SELECT *
          FROM Tasks
         WHERE Archive = 0
        #type_sql#
</CFQUERY>

This is the error that shows in my browser:

ODBC Error Code = 37000 (Syntax error or access
violation)

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 5:
Incorrect syntax near 'Enchancement'.

SQL = "SELECT * FROM Tasks WHERE Archive = 0 and
typeofissue in (''Enchancement'',''Bug'')

Somehow additional single quotes have been added
around my values.

I have tried not passing the single quotes in the
variable and SQL thinks I am trying to find a column.

Can anyone help?

Eric Post
Baylor Health Care Systems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to