Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove commas from user inputted number 1

Status
Not open for further replies.

MikeT

IS-IT--Management
Feb 1, 2001
376
US
A number that a user inputs is put into an SQL statement to update a database. However, if the user uses commas (e.g. 34,592), the syntax of the SQL statement becomes incorrect.
How do I remove the commas? Something like:
for x = 1 to len(number)
<code>
next
Am I on the right track?
 
You can use the replace funtion...

For instance, if you have a variable, myVar with the commas in it and you want to remove them altogether, just say:
Code:
replace(myVar, &quot;,&quot;, &quot;&quot;)

good luck! :)
Paul Prewett
 
Turns out if I put single quotes around the variable representing the number, the syntax remains intact.

NNNNEEEEEEEEEEEEEEEEEAAAAAAAAATTTTTTTTTOOOOOOOOOOOOO!!!!!!!!
 
Wow link9, thats a sweet idea!
I'll remember that for future reference.
Thank you for posting!

MikeT
 
Just for your information, the ' may work in SQL server but it doesn't work for Oracle. If you try to insert a string literal into a number column you will get a &quot;Invalid Number&quot; error message.

With oracle you must use the replace(string,&quot;,&quot;,&quot;&quot;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top