Subject Re: [firebird-support] Result type of RPAD() and LPAD()
Author Kjell Rilbe
Paul Vinkenoog skriver:
> > In the documentation for LPAD and RPAD is written that the result
> type is VARCHAR(32765) and there is a tip to cast the result to a useful
> length.
> >
> > When using LPAD or RPAD in a "SELECT LPAD( LABEL, 8, '-' ) FROM...",
> FlameRobin and IBExpert both return a VARCHAR(8), corresponding to the
> length argument of xPAD(), without casting.
>
> In Firebird 2.5, the result is VARCHAR(n) with n equal to the second
> argument.

Does this mean that if I have a varchar(n) col and want to pad those
values that are shorter than k chars to m chars (n >= m >= k), I can't
do it without also truncating values longer than m to m chars?

E.g. column "x" is varchar(10) and I have these values:

'abcdefghij'
'a'
'abcde'

select rpad("x", '-', 6) from thetable

would return this:

'abcdef'
'a-----'
'abcde-'

Or would it throw an exception?

Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64