Connecting Tech Pros Worldwide Help | Site Map

A Function inside a Loop

Member
 
Join Date: Jan 2008
Posts: 36
#1: Feb 15 '08
Hi,
I have a column in my table that data type is "char" some data are number and some are text, and no way I can separate them. I'm using it to write an excel sheet. Is there any function in ColdFusion that I can use that treat the numbers as numbers and text as text. May be a loop to go true the rows an where it's number apply the formula and where it's text just dump it on the excel sheet that I'm making. I'll appreciate your hint.:-)
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Feb 16 '08

re: A Function inside a Loop


Use the isNumeric function to determine whether a string is a number.
Member
 
Join Date: Jan 2008
Posts: 36
#3: Feb 18 '08

re: A Function inside a Loop


Thank you for the reply acoder,

When I use isnumeric then it replace my string by 0. Here is what I have in my SQL to retrieve the data:

Select convert2, LeadInventory, (CASE WHEN convert2 ='n' THEN convert(int , firstDay) ELSE isNumeric(firstday) END) as firstday

from Mytable


Sometimes the value in "firstday" column is a number and sometimes is an Excel formula. and IsNumeric function will replace 0 by my formula.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Feb 18 '08

re: A Function inside a Loop


You're using isNumeric (which returns a boolean) as a MySQL function.

I meant for you to use isNumeric as a function to determine whether the field was a number or not and then, depending on that, apply the formula or otherwise.
Member
 
Join Date: Jan 2008
Posts: 36
#5: Feb 18 '08

re: A Function inside a Loop


Thanks so much. I got it. you're great!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#6: Feb 19 '08

re: A Function inside a Loop


You're welcome. Glad to hear that you got it working.
Reply