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

> I tried it in 2.1.3.18185. It truncates to 6 chars.
>
> So, padding to less than the longest occurring value would require
> something like this, then:
>
> select
> case
> when character_length(x) > 6
> then x
> else rpad(x, 6, '-')
> end "Result"
> from thetable
>
> But when I tried this, I got an error:
> ------------------------------------
> Message: isc_dsql_prepare failed
>
> SQL Message : -204
> Undefined name
>
> Engine Code : 335544569
> Engine Message :
> Dynamic SQL Error
> SQL error code = -204
> Implementation limit exceeded
> block size exceeds implementation restriction
> ------------------------------------
>
> What limit did I exceed exactly?

This looks like a bug, because the select returns one column: a varchar(32765).
Maybe the engine doesn't do the math right when CASE is involved.

OTOH, if I do this in 2.1.3:

select case when 1=1 then cast ('a' as varchar(32765))
else cast ('b' as varchar(32765)) end
from rdb$database

I get a nice VARCHAR(32765) 'a'.


Paul Vinkenoog