× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 08-Jan-2015 09:04 -0600, Glenn Gundermann wrote:
How's this?:

select
cast(substr((IXXXX * 10000),1,5) as decimal(5,0)) *.001 as width
,cast(substr((IXXXX * 10000),6,6) as decimal(6,0)) *.001 as length
from ...


Not so good. As I had noted in my prior reply [although for this specific example, arguably incorrectly implying a more problematic effect than actual, except if width=zero is allowed], the expression "SUBSTR((IXXXX*10000),1,5)" is flawed because the result of the implicit cast to character of (IXXXX*10000) results in a string value that is a _left-justified_ numeric representation, so the first five characters are not in fixed positions, but the substring operation is coded such that the result must be static in size. The following example exhibits the flaw:

create table qtemp/t7
( IXXXX DECIMAL(11, 4)
)
;
insert into qtemp/t7 values(5533366.6333),(0533306.6333)
; /* w1=55.333, l1=666.333; w2=05.333, l2=066.333 */
select ... /* as quoted above, with FROM QTEMP/T7 */
; -- the report follows:
....+....1....+....2....+
WIDTH LENGTH
55.333 666.333
53.330 66.333
; -- notice how the 2nd WIDTH<>05.333 though 05.333 was stored


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.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 on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.