Re: How to do...well...any thing...in DB2 SQL
7. Casting number to a string
<quote>
CHAR
The CHAR function returns a fixed-length character string representation of:
An integer number, if the first argument is a SMALLINT, INTEGER, or BIGINT
Note: The CAST expression can also be used to return a string expression.
</quote>
So of couse this works:
SELECT CHAR(SomeBigInt ColumnFieldArma dillo) FROM MyTable
i would prefer to use CAST when doing all casts, and the documentation says
i can. But this fails
SELECT CAST(SomeBigInt ColumnFieldArma dillo AS varchar(50)) FROM MyTable
Error: SQL0461N
A value with data type "SYSIBM.BIG INT" cannot be CAST to type
"SYSIBM.VARCHAR ".
SQLSTATE=42846
(State:42846, Native Code: FFFFFE33)
Any ideas?
7. Casting number to a string
<quote>
CHAR
The CHAR function returns a fixed-length character string representation of:
An integer number, if the first argument is a SMALLINT, INTEGER, or BIGINT
Note: The CAST expression can also be used to return a string expression.
</quote>
So of couse this works:
SELECT CHAR(SomeBigInt ColumnFieldArma dillo) FROM MyTable
i would prefer to use CAST when doing all casts, and the documentation says
i can. But this fails
SELECT CAST(SomeBigInt ColumnFieldArma dillo AS varchar(50)) FROM MyTable
Error: SQL0461N
A value with data type "SYSIBM.BIG INT" cannot be CAST to type
"SYSIBM.VARCHAR ".
SQLSTATE=42846
(State:42846, Native Code: FFFFFE33)
Any ideas?
Comment