Subject | Re: [firebird-support] Result type of RPAD() and LPAD() |
---|---|
Author | Kjell Rilbe |
Post date | 2011-01-10T12:08:54Z |
Paul Vinkenoog skriver:
select
case when character_length(x) > 6
then x
else cast(rpad(x, 6, '-') as varchar(10))
end "Result"
from thetable
This works fine.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
>OK. I tried this:
>
> Kjell Rilbe wrote:
>
> > 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'.
select
case when character_length(x) > 6
then x
else cast(rpad(x, 6, '-') as varchar(10))
end "Result"
from thetable
This works fine.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64