此内容没有您所选择的语言版本。

4.2. Type Conversions


Data types may be converted from one form to another either explicitly or implicitly. Implicit conversions automatically occur in criteria and expressions to ease development. Explicit data type conversions require the use of the CONVERT function or CAST keyword.
Type Conversion Considerations
  • Any type may be implicitly converted to the OBJECT type.
  • The OBJECT type may be explicitly converted to any other type.
  • The NULL value may be converted to any type.
  • Any valid implicit conversion is also a valid explicit conversion.
  • Situations involving literal values that would normally require explicit conversions may have the explicit conversion applied implicitly if no loss of information occurs.
  • When JBoss Data Virtualization detects that an explicit conversion can not be applied implicitly in criteria, the criteria will be treated as false. For example:
    SELECT * FROM my.table WHERE created_by = 'not a date'
    Copy to Clipboard Toggle word wrap
    Given that created_by is typed as date, rather than converting 'not a date' to a date value, the criteria will remain as a string comparison and therefore be false.
  • Explicit conversions that are not allowed between two types will result in an exception before execution. Allowed explicit conversions may still fail during processing if the runtime values are not actually convertible.
  • Warning

    The JBoss Data Virtualization conversions of float/double/bigdecimal/timestamp to string rely on the JDBC/Java defined output formats. Pushdown behavior attempts to mimic these results, but may vary depending upon the actual source type and conversion logic. Care must be taken to not assume the string form in criteria or other places where a variation may cause different results.
Expand
Table 4.2. Type Conversions
Source Type Valid Implicit Target Types Valid Explicit Target Types
string clob char, boolean, byte, short, integer, long, biginteger, float, double, bigdecimal, xml [a]
char string  
boolean string, byte, short, integer, long, biginteger, float, double, bigdecimal  
byte string, short, integer, long, biginteger, float, double, bigdecimal boolean
short string, integer, long, biginteger, float, double, bigdecimal boolean, byte
integer string, long, biginteger, double, bigdecimal boolean, byte, short, float
long string, biginteger, bigdecimal boolean, byte, short, integer, float, double
biginteger string, bigdecimal boolean, byte, short, integer, long, float, double
bigdecimal string boolean, byte, short, integer, long, biginteger, float, double
date string, timestamp  
time string, timestamp  
timestamp string date, time
clob   string
xml   string [b]
[a] string to xml is equivlant to XMLPARSE(DOCUMENT exp) - see Section 3.4.14, “XML Functions”.
[b] xml to string is equivalent to XMLSERIALIZE(exp AS STRING) - see Section 3.4.14, “XML Functions”.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat