On 13 Feb 2013 22:38, CRPence wrote:
<<SNIP>>
≥ mod(length(digits(ifnull(m.OrderQty, dec(0, 1)))), 2) odd_prec
<<SNIP>>
The above expression will fail to produce expected results whenever
the precision=scale for the column OrderQty, thus the given query can
not be used to validate packed decimal when the column being reviewed
for bad decimal data has a precision=scale. Ugh :-( That lack of
PRECISION and SCALE scalars definitely seems to be a problem for making
a solution with just some expressions in a query.
Maybe that remaining stumbling-block will motivate me to finally
create the PROCEDURE that would create a VIEW in QTEMP using the column
LENGTH and NUMERIC_SCALE from SYSCOLUMNS to generate the necessary logic
to validate all BCD columns of a named physical file [which presumably
would normally not be a TABLE because a TABLE should be protected from
the issue of bad decimal data, unlike the DDS PF]. If so, I will
probably encapsulate the validation [for both PACKED decimal and ZONED
decimal] in a single UDF invoked effectively like the following,
returning a zero for false and a one for true:
VALID_BCD(HEX(column_name), DATA_TYPE, LENGTH, NUMERIC_SCALE)