use:
<cfquery name="qname" datasource="#request.dsn#">
SELECT *
FROM tablename
WHERE #preservesinglequotes(where)#
</cfquery>
to stop the quotes being escaped.
> -----Original Message-----
> From: Tim Blair [mailto:[EMAIL PROTECTED]]
> Sent: 15 October 2002 15:52
> To: [EMAIL PROTECTED]
> Subject: [ cf-dev ] Problem with dynamic 'where' clause
>
>
>
> Brainache time (for me)...
>
> I've got a SQL statement where the "where" clause is build up
> programatically, depending on the option a user seleted:
>
> <cfswitch expression="#attributes.type#">
> <cfcase case="1">
> <cfset where = "otherkey = #attributes.q#">
> </cfcase>
> ...
> <cfdefaultcase>
> <cfset where = "tablekey = #attributes.q# OR tablecol =
> '#attributes.q#'">
> </cfdefaultcase>
> </cfswitch>
>
> <cfquery name="qname" datasource="#request.dsn#">
> SELECT *
> FROM tablename
> WHERE #where#
> </cfquery>
>
> All looks well and good, but when this is run (CF5) passing something
> that fires off the "default" case and with attributes.q EQ 50000126, I
> get an error "Syntax error or access violation - Incorrect syntax near
> '50000126'."
>
> If I <cfoutput> the query and then c&p into query analyser, it works
> fine:
>
> SELECT *
> FROM tablename
> WHERE tablekey = 50000126 OR tablecol = '50000126'
>
> Any ideas?
>
> Cheers,
>
> Tim.
>
>
> -------------------------------------------------------
> Tim Blair
> Web Application Engineer, Rawnet Limited
> Direct Phone : +44 (0) 1344 393 441
> Switchboard : +44 (0) 1344 393 040
> -------------------------------------------------------
> rawnet ltd
> Atrium Court
> Bracknell [EMAIL PROTECTED]
> Berkshire Tel : +44 (0) 1344 393 040
> RG12 1BW, UK http://www.rawnet.com
> -------------------------------------------------------
> This message may contain information which is legally
> privileged and/or confidential. If you are not the
> intended recipient, you are hereby notified that any
> unauthorised disclosure, copying, distribution or use
> of this information is strictly prohibited. Such
> notification notwithstanding, any comments, opinions,
> information or conclusions expressed in this message
> are those of the originator, not of rawnet limited,
> unless otherwise explicitly and independently indicated
> by an authorised representative of rawnet limited.
> -------------------------------------------------------
>
>
>
>
>
> --
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For human help, e-mail: [EMAIL PROTECTED]
>
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]