Question

I have table called DART_STG1 in Netezza Database. The table has a varchar column. I am trying to use the below SQL to convert the varchar into a number, but it always throws an error.

Code

SELECT DISTINCT TO_NUMBER(M12,'99G99') 
FROM   DART_STG1 
WHERE  M12 IS NOT NULL;

Throws an error:

ERROR [HY000] ERROR: Bad numeric input format

What does this error mean?

Was it helpful?

Solution 2

The error:

ERROR [HY000] ERROR: Bad numeric input format 

Is caused because you feeding letters into TO_NUMBER. You are feeding it 99G99 which is not a number.

The program tries to tell you it's not a number by telling you that the numeric input format is bad, as the error very clearly says.

OTHER TIPS

The PDA (Netezza) Conversion functions page provide examples, and together with the Template patterns, you can choose the appropriate format.

However I'm getting the same error for my data set. I'm suspecting it's something about the formatting of the values in STORE_NUMBER is what Netezza doesn't like.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top