I have written a seemingly simple UDF for cleaning up data before an insert or update statement (it trims the string, inserts null when necessary, wraps string in single quotes if it's a char field):
<cfscript> function checknull(ii,isint) { if (isint) { return iif(len(trim(ii)),de(trim(ii)),de("null")); } else { return iif(len(trim(ii)),de(chr(39)&trim(ii)&chr(39)),de("null")); } } </cfscript> Basically, my insert statement looks like: Insert into tablename (intfield,charfield) Values (#checknull(intfield,1)#,#checknull(charfield,0)#) It works great except for when the charfield contains apostrophes. It escapes them all and the result is that twice as many apostrophes get inserted. I know that somewhere in here I should probably be using preservesinglequotes() but everywhere I attempt to use it in the UDF I get a JIT compilation error. I also get a JIT if I put the preservesinglequotes function in the calling template [preservesinglequotes(checknull(charfield,0))] Any suggestions? Please? Unfortunately I used this function all through an app before finding the bug, so I would be psyched to make repairs to the function itself not all the code that uses it. - Sean ~~~~~~~~~~~~~~~~~~~~~~~~~~ Sean Daniels Director, Engineering Marketplace Technologies, Inc (T): 207.363.7374 (C): 207.332.6340 (F): 240.269.6319 ~~~~~~~~~~~~~~~~~~~~~~~~~~ http://www.dealforce.com http://www.mergernetwork.com ______________________________________________________________________ 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 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists