<cfif IsDefined("uid")>
> <cfset select_condition="userid=#uid#">
> </cfif>
> <cfif IsDefined("unm")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND username='#unm#'">
> <cfelse>
> <cfset select_condition="username='#unm#'">
> </cfif>
Is uid always defined? If not, there is the chance that you end up with
select_condition being:
"" AND username='#unm#'
which isn't valid syntax (I think).
Does the error message tell you exactly which part of the code is throwing
the syntax error?
Duncan Cumming
IT Manager
http://www.alienationdesign.co.uk
mailto:[EMAIL PROTECTED]
Tel: 0141 575 9700
Fax: 0141 575 9600
Creative solutions in a technical world
----------------------------------------------------------------------
Get your domain names online from:
http://www.alienationdomains.co.uk
Reseller options available!
----------------------------------------------------------------------
----------------------------------------------------------------------
Bo Jiang
<[EMAIL PROTECTED] To: [EMAIL PROTECTED]
nt.ucd.ie> cc:
Subject: Re: [ cf-dev ] string and
numeric
27/11/2003 13:43
Please respond to
dev
Hi,
Please, any body can give me a clue about my question? Is that infeasible
in CF?
Is there any alternative way to do that? Thanks a lot.
Advice welcome
Bo Jiang
----- Original Message -----
From: "Bo Jiang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 27, 2003 9:04 AM
Subject: [ cf-dev ] string and numeric
> Hi,
> I am doing two functions in CF a component. One has arguments all in
numeric, it works fine, another has some arguments in string, when I quote
the variable in a SQL, it says syntax error. As far as I can see, that
because the single quotation marks are converted to double quotation marks
automatically. What can I do to get it work?
> Thanks
>
> Bo
>
> ********This one with string arguments doesn't work******
> <cffunction name="getuserinfo" access="public" returntype="query">
> <cfargument name="uid" type="numeric" required="no">
> <cfargument name="unm" type="string" required="no">
> <cfargument name="uem" type="string" required="no">
> <cfargument name="ufn" type="string" required="no">
> <cfargument name="uln" type="string" required="no">
> <cfset select_condition="">
> <cfquery name="usrinfo" datasource="opps">
> <cfif IsDefined("uid")>
> <cfset select_condition="userid=#uid#">
> </cfif>
> <cfif IsDefined("unm")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND username='#unm#'">
> <cfelse>
> <cfset select_condition="username='#unm#'">
> </cfif>
> </cfif>
> <cfif IsDefined("uem")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND email='#uem#'">
> <cfelse>
> <cfset select_condition="email='#uem#'">
> </cfif>
> </cfif>
> <cfif IsDefined("ufn")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND firstname='#ufn#'">
> <cfelse>
> <cfset select_condition="firstname='#ufn#'">
> </cfif>
> </cfif>
> <cfif IsDefined("uln")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND lastname='#uln#'">
> <cfelse>
> <cfset select_condition="lastname='#uln#'">
> </cfif>
> </cfif>
> <cfif len(select_condition) gt 0>
> Select * from user where #select_condition#
> <cfelse>
> Select * from user
> </cfif>
> </cfquery>
> <cfreturn usrinfo>
> </cffunction>
>
> ******This one with all numeric arguments works fine*********
> <cffunction name="getads" access="public" returntype="query">
> <cfargument name="eid" type="numeric" required="no">
> <cfargument name="uid" type="numeric" required="no">
> <cfargument name="cid" type="numeric" required="no">
> <cfargument name="pid" type="numeric" required="no">
> <cfargument name="rid" type="numeric" required="no">
> <cfset select_condition="">
> <cfquery name="adsout" datasource="opps">
> <cfif IsDefined("eid")>
> <cfset select_condition="eventid=#eid#">
> </cfif>
> <cfif IsDefined("uid")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND userid=#uid#">
> <cfelse>
> <cfset select_condition="userid=#uid#">
> </cfif>
> </cfif>
> <cfif IsDefined("cid")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND categoryid=#cid#">
> <cfelse>
> <cfset select_condition="categoryid=#cid#">
> </cfif>
> </cfif>
> <cfif IsDefined("pid")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND productid=#pid#">
> <cfelse>
> <cfset select_condition="productid=#pid#">
> </cfif>
> </cfif>
> <cfif IsDefined("rid")>
> <cfif len(select_condition) gt 0>
> <cfset select_condition="#select_condition# AND rank=#rid#">
> <cfelse>
> <cfset select_condition="rank=#rid#">
> </cfif>
> </cfif>
> <cfif len(select_condition) gt 0>
> Select * from ads where #select_condition#
> <cfelse>
> Select * from ads
> </cfif>
> </cfquery>
> <cfreturn adsout>
> </cffunction>
>
--
** 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]