On 11 Feb 2013 08:45, Jeff Young wrote:
Try this:
SELECT f1.f2.etc.
from Datafile
where substr(OrderQty, 1, 1) = x'40'
Replace the f1,f2,etc with field names from the file, but not the
OrderQty which SQL will see as invalid data.

What columns are on the select column list is moot, if the selection properly effects omission of all of the rows with the invalid decimal value [for the OrderQty field in this case].

The given query should fail with a selection error due to decimal data errors. The implicit cast to character effected by the use of the SUBSTR does not ameliorate the issue for bad data. AFaIK only the HEX() scalar enables access to the data in the column when the data in that column is not valid.

Also whenever using any numeric cast to character, whether implicit or explicitly with something like the CHAR, VARCHAR, or DIGITS casting scalars, best to always explicitly assign\cast the column numeric length and scale to avoid problems due to changes of the base column.

This thread ...


Return to Archive home page | Return to MIDRANGE.COM home page