MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » February 2013

Re: SQL: how to filter out spaces in fields defined as packed numeric



fixed

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.






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

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact