|
Hm, that is interesting. What you describe is in line with what the
SQL Reference (7.1) states,
but a little test with STRSQL (7.1) seems to contradict it:
Given that foo is a char(30) column in table bar, with actual values
ranging in length from 8 to 30, the following:
select foo
, length(trim(foo))
, substr(trim(foo), 10, 30)
, length(substr(trim(foo), 10, 30)) /* <ed:> fourth /column/ */
from bar
returns 30 in the fourth column for all rows. That remains true
when foo is varchar(30), char(1) or varchar(1).
Even though the reference explicitly says 'If length is explicitly
specified, padding is not performed.', it appears that padding is
performed.
Although I always accepted the behaviour of the RPG compiler as
logical, I agree that the way SQL apparently handles it would have
been preferable.
Op 25 feb. 2013, om 19:59 heeft CRPence het volgende geschreven:
Odd that the RPG does not simply return the empty string for the
result of the %subst opcode in that example, and therefore evaluate
to false for the comparison. Any substring of a varying variable
that has the value of the empty-string is always the empty-string,
much like the product of any numeric with the zero-value is always
zero. FWiW the SQL will return the empty-string in that case using
its SUBSTR scalar function [and LEFT, RIGHT, ¿and others?].
<<SNIP>>
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.