You can't define a NUMBER Format for a CHAR
field in external table. It is only possible to define a [date_format_spec][1]
(i.e. control the format of a DATE
column)
You apparently can't use the LOAD WHEN
to skip a number with decimal places as well, as only equal or not equal operators are allowed. (Not really sure as I didn't found
this in documentation, but I failed using LIKE
)
What should be possible, is to set the decimal point character in a such way, that the conversion fails (in your case other than .
) and the record will be rejected with
ORA-01722: invalid number
Unfortunately you can't use alter session set NLS_NUMERIC_CHARACTERS
as this is ignored in the external table.
In Oracle 12r2 there is a parameter TERRITORY
that should serve this purpose. Try to set it to territory where the default decimal character is other than .
This should work.
Tested fine in 12.2.0.1.0
Using this file
PT;200
PT;200.04
that has point as a decimal character you make define the expected decimal character in the external table with the TERRITORY parameter
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
TERRITORY AMERICA
FIELDS TERMINATED BY ';'
For TERRITORY AMERICA both records are selected (as the number can be parsed)
ENTIDADE_NAME ENTIDADE_AGE
-------------------------------------------------- ------------
PT 200
PT 200,04
Now change the TERRITORY
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
TERRITORY GERMANY
FIELDS TERMINATED BY ';'
For TERRITORY GERMANY (as en example where comma as a decimal character) only the first record is processed.
The second one is rejected as the number can't be parsed
ENTIDADE_NAME ENTIDADE_AGE
-------------------------------------------------- ------------
PT 200
Which is your expected behaviour.
In the log file you see
ORA-01722: Ungültige Zahl
which is German for ORA-01722: invalid number