[
https://issues.apache.org/jira/browse/DERBY-2072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17154473#comment-17154473
]
Lukas Eder commented on DERBY-2072:
-----------------------------------
For the record, this can be circumvented by casting to CHAR first:
{code}
VALUES CAST(CAST(123 AS CHAR(38)) AS VARCHAR(10))
{code}
> Implement CAST from INTEGER (and other numeric types) to VARCHAR
> ----------------------------------------------------------------
>
> Key: DERBY-2072
> URL: https://issues.apache.org/jira/browse/DERBY-2072
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Reporter: Christian d'Heureuse
> Priority: Major
> Labels: derby_triage10_11
>
> While CASTs from DATE/TIME to VARCHAR and from INTEGER to CHAR are allowed,
> the conversion from INTEGER to VARCHAR is not supported.
> The statement
> VALUES CAST(123 as VARCHAR(10))
> produces the error
> Cannot convert types 'INTEGER' to 'VARCHAR'.
> The function
> org.apache.derby.impl.sql.compile.BaseTypeCompiler.numberConvertible()
> returns false for a conversion from INTEGER to VARCHAR. This is documented
> within a comment in the source code, but it's not documented why.this is so.
> (Another documented rule in numberConvertible() is that floating point types
> can only be converted to CHAR by the CHAR() function and not with a CAST.
> There is also no indication of why this is so.)
> See also DERBY-1289, DERBY-1306 and DERBY-1804.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)