In Oracle, I want to know if a string value is numeric only. How can I do this?

Views: 33

Reply to This

Replies to This Discussion

To test a string for numeric characters, you could use a combination of the length function, trim function, and translate function built into Oracle.

You can use the following command:

LENGTH(TRIM(TRANSLATE(string1, ' +-.0123456789', ' ')))
string1 is the string value that you are testing

This function will return a null value if string1 is numeric. It will return a value "greater than 0" if string1 contains any non-numeric characters.

Reply to Discussion

RSS

© 2020   Created by Maisam Agha.   Powered by

Badges  |  Report an Issue  |  Terms of Service