Subject Re: [firebird-support] Result type of RPAD() and LPAD()
Author Paul Vinkenoog
Hello Kjell,

> > 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
>
> Sorry, that should be:
> select rpad("x", 6, '-') from thetable
>
> > would return this:
> >
> > 'abcdef'
> > 'a-----'
> > 'abcde-'
> >
> > Or would it throw an exception?

No, not an exception; strings longer then <endlen> will be truncated. If you want
to prevent this, you have to do something like

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


Paul Vinkenoog