Junior Developer have some doubts in CF_SQL_NUMERIC

Reply

Join Date: Aug 2004
Posts: 2
Reputation: mayoline is an unknown quantity at this point 
Solved Threads: 0
mayoline mayoline is offline Offline
Newbie Poster

Junior Developer have some doubts in CF_SQL_NUMERIC

 
0
  #1
Aug 3rd, 2004
Hello, experts out there. First of all, thanks for reading my threads.

I am a junior developer using ColdFusion. I have some doubts here.

When we passing the parameters which is numeric type, then use that variable in another page for query, sometimes will come out with error of CF_SQL_NUMERIC, even we just #trim(variable)#.

When i meet such problem, i always #val(variable)# in order to get back the numeric value. It works if the variable when i have full confidence the variable is a numeric type. But is this the proper way to fix this?? Or anyone can tell me the correct way and the impact by #val()# the variable??


Thanks for help. :mrgreen:
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 8
Reputation: rameshsambu is an unknown quantity at this point 
Solved Threads: 0
rameshsambu's Avatar
rameshsambu rameshsambu is offline Offline
Newbie Poster

Re: Junior Developer have some doubts in CF_SQL_NUMERIC

 
0
  #2
Nov 3rd, 2006
Hi mayoline

Trim() will only remove the leading and trailing spaces. It wont convert string to a number.

Val() will convert those characters in the beginning of a string which can be converted to a number.

Val always returns a number. Even if the conversion fails it will return 0.

Use val() whereever you want strictly numeric values (like in calculations)

In those cases where you strictly need a non-zero number, check if the value returned by val() is 0 or not and then proceed.

-Ramesh
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 2
Reputation: mayoline is an unknown quantity at this point 
Solved Threads: 0
mayoline mayoline is offline Offline
Newbie Poster

Re: Junior Developer have some doubts in CF_SQL_NUMERIC

 
0
  #3
Nov 6th, 2006
Thanks for your reply.

Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC