

So this method would catch the fact that -+1.8++- is not a valid number. You could execute the is_number function as follows: SELECT is_number('123') FROM dual This new function called is_number would return 1 if the value is numeric and 0 if the value is NOT numeric.

A better way to test a string for a numeric value is to create your own function that uses the TO_NUMBER function to test the string value.įor example: CREATE FUNCTION is_number (p_string IN VARCHAR2) SELECT LENGTH(TRIM(TRANSLATE ('-56', ' +-.0123456789',' '))) FROM dual Īlthough this first method will test a string if it is a properly formatted number, it would allow a number to pass such as -+1.8++-, which is of course not a number. It will return a value "greater than 0" if string1 contains any non-numeric characters.įor example, SELECT LENGTH(TRIM(TRANSLATE('123b', ' +-.0123456789',' '))) FROM dual It will return a null value if string1 is numeric. Eight percent of all males are affected by color vision impairment make sure that your graphical work is readable by the widest possible audience.
#Color oracle quiz full#
This solution uses the TRANSLATE, LENGTH, and TRIM functions to test a string for a numeric value if the numeric value is properly formatted. Color Oracle applies a full screen color filter to art you are designing, independently of the software in use. You can use the following command: LENGTH(TRIM(TRANSLATE(string1, ' +-.0123456789', ' '))) string1 The string value that you are testing. How can I do this?Īnswer: To test a string for numeric characters, you could use a combination of the LENGTH function, TRIM function, and TRANSLATE function built into Oracle. Question: In Oracle, I want to know if a string value is numeric only. (1) Points Database Memory System Database Management Software Database Manipulation System Database Management System () Correct 7. Section 1 (Answer all questions in this section) 6. An asterisk () indicates a correct answer. Oracle / PLSQL: Test a string for a numeric value Test: DFo Section 1 Quiz Review your answers, feedback, and question scores below.
