Monday, October 20, 2014
01722. 00000 - "invalid number"
Recently used SQLLDR to upload about 1.5M records from a number of files into a table supporting report queries using aggregate functions such as sum(...). Did not realize that the download file was in Windows format, so the carriage returns(\r) got into the column value as the control file was built for newline as follows.
infile 'file1.csv' "str '\n'"
when running select sum(trim(amt)) ...., ran into
ORA-01722: invalid number
01722. 00000 - "invalid number"
*Cause: The specified number was invalid.
*Action: Specify a valid number.
Ran many regexp_like(...) on the columns, and also egrep on file contents to look for patterns and did not catch any.
After some dabbling, finally found the rows having this issue out of 1.5M records.
Thanks to this post showing two ways to find \r or \n
http://stackoverflow.com/questions/12712480/sql-query-to-test-if-string-value-contains-carriage-return
Did a simple update as ... amt = replace(amt,CHR(13),'')...
Subscribe to:
Posts (Atom)