Derby
  1. Derby
  2. DERBY-2072

Implement CAST from INTEGER (and other numeric types) to VARCHAR

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: SQL
    • Urgency:
      Normal

      Description

      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.

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              Christian d'Heureuse
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development