This may help.

 

You can use this to loop over the variables in a form:

 

<!--- dummy form data --->

<cfset form = {} />

<cfset myList = "" />

<cfset form.var1 = "Name" />

<cfset form.var2 = "LastName" />

 

<!--- Bild a csv list --->

<cfloop collection="#form#" item="key">

      <cfset myList &= form[key] & "," />

</cfloop>

 

<!--- drop the last " , " --->

<cfset myList = left(myList,len(myList)-1) />

 

Also remember to use cfqueryparam.

.. and column IN <cfqueryparam list="true" cfsqltype="cf_sql_varchar"
value="#myList#" />

 

Paul.

http://blog.kukiel.net

 

 


From: Vineet Garg [mailto:[email protected]] 
Sent: Wednesday, September 23, 2009 7:30 AM
To: cf-newbie
Subject: How do I put the form variables in quoted value list to make it
usable in SQL query

 

 

Hi,

 

I have some variables in form which may or may not be defined. Now I want to
use these variables in IN clause of a SQL query. i.e Select * from
<tablename> where <condition> and column IN
('#form.var1$#','#form.var2#'..).

Is there any function in coldfusion to convert the form variables into
quoted value list. I know there is a function QuotedValueList() to convert
query column values. Is there anything similar to this for form variables?

 

Thanks in advance.

 

 

Regards,

Vineet Garg.

 

This message and the information contained herein is proprietary and
confidential and subject to the Amdocs policy statement,

you may review at http://www.amdocs.com/email_disclaimer.asp

 

 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4815
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to