db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: Concatenating two numbers as a string
Date Mon, 05 May 2008 14:41:05 GMT
Bogdan Calmac wrote:
> To concatenate two numbers in a string you have to do something like this (in
> derby 10.3):
>
> trim(char(min_value)) || trim(char(max_value))
>
> This is pretty ugly, considering that it could have been as simple as:
>
> min_value || max_value
>
> Also, the documentation for the concatenate operator states that "Because
> all built-in data types are implicitly converted to strings, this function
> can act on all built-in data types". Is the documentation wrong?
>
> While trying different things, I noticed that numeric types cannot be cast
> to VARCHAR (which is also specified in the documentation). Is there some
> technical limitation to prevent such a natural conversion?
>   
As a workaround, you can write your own casting function. Please see the 
CREATE FUNCTION section of the Derby Reference Manual. E.g.,

  select castIntToVarchar( a ) from t

Hope this helps,
-Rick

Mime
View raw message