Skip to content
Advertisement

TO_NUMBER() Function In Oracle Behaves Differently

I have string variables and these variables differ in length. Let’s assume that I have the following strings:

I want to convert my string variables to float. So, to do that, I call TO_NUMBER() function. The problem is when I call TO_NUMBER() function from my .NET web application instead of calling it directly within pl/sql block, it gives me an “invalid number” error.

I want to be able to call TO_NUMBER() function from both my web application and within pl/sql block at the same time. Because it is in a stored procedure. I think that is something about NLS Parameters. But I couldn’t make it work.

To sum up:

TO_NUMBER(string) syntax works fine if I call the function within PL/SQL block. But it gives me an “invalid number” error when I call it from my web application.

I want the exact value in float data type.

Advertisement

Answer

You might also want to call TO_NUMBER with the right NLS_NUMERIC_CHARACTER settings to avoid conflicts between your application side and your database side

Then

If you believe you might have no number, use @Gordon Linoff answer to look for non numeric values.

With different NLS settings

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement