Re: Building and saving a query string
Remove ALL extra characters using cfsetting enablecfoutputonly=yes and then put cfoutput/cfoutput around all characters you want to keep, like this... cfsetting enablecfoutputonly=yes cfsavecontent variable=myquery cfoutputSelect * from contacts where 1 /cfoutput cfif Form.company IS NOT Allcfoutput and company like '%#Form.company#%'/cfoutput/cfif cfif Form.title IS NOT Allcfoutput and title like '%#Form.title#%'/cfoutput/cfif cfif Form.city IS NOT Allcfoutput and city like '%#Form.city#%'/cfoutput/cfif cfif Form.state IS NOT Allcfoutput and state like '%#Form.state#%'/cfoutput/cfif cfif Form.country IS NOT Allcfoutput and country like '%#Form.country#%'/cfoutput/cfif cfif Form.type IS NOT Allcfoutput and type_of_industry like '%#Form.type#%'/cfoutput/cfif cfif Form.size IS NOT Allcfoutput and company_size = #Form.size#/cfoutput/cfif cfif Form.department IS NOT Allcfoutput and department like '%#Form.department#%'/cfoutput/cfif cfif Form.source IS NOT Allcfoutput and source_of_contact like '%#Form.source#%'/cfoutput/cfif /cfsavecontent cfsetting enablecfoutputonly=no On 1/8/03 1:49 PM, Luis Lebron [EMAIL PROTECTED] wrote: I'm using the following code to build and display a query string:\ cfsavecontent variable=myquery Select * from contacts where 1 cfif Form.company IS NOT Alland company like '%cfoutput#Form.company#/cfoutput%'/cfif cfif Form.title IS NOT Alland title like '%cfoutput#Form.title#/cfoutput%'/cfif cfif Form.city IS NOT Alland city like '%cfoutput#Form.city#/cfoutput%'/cfif cfif Form.state IS NOT Alland state like '%cfoutput#Form.state#/cfoutput%'/cfif cfif Form.country IS NOT Alland country like '%cfoutput#Form.country#/cfoutput%'/cfif cfif Form.type IS NOT Alland type_of_industry like '%cfoutput#Form.type#/cfoutput%'/cfif cfif Form.size IS NOT Alland company_size cfoutput#Form.size#/cfoutput/cfif cfif Form.department IS NOT Alland department like '%cfoutput#Form.department#/cfoutput%'/cfif cfif Form.source IS NOT Alland source_of_contact like '%cfoutput#Form.source#/cfoutput%'/cfif /cfsavecontent cfoutput#(myquery)# /cfoutput The query string builds and displays correctly. For example: Select * from contacts where 1 and company like '%Company 1%' and title like '%Title 1%' and type_of_industry like '%Manufacturing%' and company_size 250 and department like '%Training% However, when I try to save the query string in the database later it has a lot of unneeded spaces and line breaks like so: Select * from contacts where 1 and company like '%Company 1%' and title like '%Title 1%' and type_of_industry like '%Manufacturing%' and company_size 250 and department like '%Training%' Is there any way I can fix this? thanks, Luis ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Building and saving a query string
I ended up writing a function to strip the newlines cffunction name=StripNL returnType=string cfargument name=string type=string cfreturn replace(string, #chr(10)#, , all) /cffunction That did the trick. thanks, Luis -Original Message- From: John Paul Ashenfelter [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 4:20 PM To: CF-Talk Subject: Re: Building and saving a query string Lots of options: 1) StripCR() CF function 2) Regex for stripping extra CR/LF/spaces 3) database functions for text processing 4) search/replace in either cf or db. I'd try StripCR as a start. Regards, John Paul Ashenfelter CTO/Transitionpoint [EMAIL PROTECTED] - Original Message - From: Luis Lebron [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, January 08, 2003 4:49 PM Subject: Building and saving a query string I'm using the following code to build and display a query string:\ cfsavecontent variable=myquery Select * from contacts where 1 cfif Form.company IS NOT Alland company like '%cfoutput#Form.company#/cfoutput%'/cfif cfif Form.title IS NOT Alland title like '%cfoutput#Form.title#/cfoutput%'/cfif cfif Form.city IS NOT Alland city like '%cfoutput#Form.city#/cfoutput%'/cfif cfif Form.state IS NOT Alland state like '%cfoutput#Form.state#/cfoutput%'/cfif cfif Form.country IS NOT Alland country like '%cfoutput#Form.country#/cfoutput%'/cfif cfif Form.type IS NOT Alland type_of_industry like '%cfoutput#Form.type#/cfoutput%'/cfif cfif Form.size IS NOT Alland company_size cfoutput#Form.size#/cfoutput/cfif cfif Form.department IS NOT Alland department like '%cfoutput#Form.department#/cfoutput%'/cfif cfif Form.source IS NOT Alland source_of_contact like '%cfoutput#Form.source#/cfoutput%'/cfif /cfsavecontent cfoutput#(myquery)# /cfoutput The query string builds and displays correctly. For example: Select * from contacts where 1 and company like '%Company 1%' and title like '%Title 1%' and type_of_industry like '%Manufacturing%' and company_size 250 and department like '%Training% However, when I try to save the query string in the database later it has a lot of unneeded spaces and line breaks like so: Select * from contacts where 1 and company like '%Company 1%' and title like '%Title 1%' and type_of_industry like '%Manufacturing%' and company_size 250 and department like '%Training%' Is there any way I can fix this? thanks, Luis ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Building and saving a query string
Lots of options: 1) StripCR() CF function 2) Regex for stripping extra CR/LF/spaces 3) database functions for text processing 4) search/replace in either cf or db. I'd try StripCR as a start. Regards, John Paul Ashenfelter CTO/Transitionpoint [EMAIL PROTECTED] - Original Message - From: Luis Lebron [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, January 08, 2003 4:49 PM Subject: Building and saving a query string I'm using the following code to build and display a query string:\ cfsavecontent variable=myquery Select * from contacts where 1 cfif Form.company IS NOT Alland company like '%cfoutput#Form.company#/cfoutput%'/cfif cfif Form.title IS NOT Alland title like '%cfoutput#Form.title#/cfoutput%'/cfif cfif Form.city IS NOT Alland city like '%cfoutput#Form.city#/cfoutput%'/cfif cfif Form.state IS NOT Alland state like '%cfoutput#Form.state#/cfoutput%'/cfif cfif Form.country IS NOT Alland country like '%cfoutput#Form.country#/cfoutput%'/cfif cfif Form.type IS NOT Alland type_of_industry like '%cfoutput#Form.type#/cfoutput%'/cfif cfif Form.size IS NOT Alland company_size cfoutput#Form.size#/cfoutput/cfif cfif Form.department IS NOT Alland department like '%cfoutput#Form.department#/cfoutput%'/cfif cfif Form.source IS NOT Alland source_of_contact like '%cfoutput#Form.source#/cfoutput%'/cfif /cfsavecontent cfoutput#(myquery)# /cfoutput The query string builds and displays correctly. For example: Select * from contacts where 1 and company like '%Company 1%' and title like '%Title 1%' and type_of_industry like '%Manufacturing%' and company_size 250 and department like '%Training% However, when I try to save the query string in the database later it has a lot of unneeded spaces and line breaks like so: Select * from contacts where 1 and company like '%Company 1%' and title like '%Title 1%' and type_of_industry like '%Manufacturing%' and company_size 250 and department like '%Training%' Is there any way I can fix this? thanks, Luis ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4