HSQLDB:重复的列名,不支持的内部操作:类型,强制转换字符无效

Posted

技术标签:

【中文标题】HSQLDB:重复的列名,不支持的内部操作:类型,强制转换字符无效【英文标题】:HSQLDB: Duplicate column name, unsupported internal operation: Type, invalid character for cast 【发布时间】:2010-07-24 03:27:41 【问题描述】:

我从 HSQLDB 开始,但遇到了这个问题,无法弄清楚发生了什么:

CREATE TEXT TABLE ozizkaindata (
  jobName VARCHAR(255) NOT NULL,
  buildNumber VARCHAR(255) NOT NULL,
  config VARCHAR(255) NOT NULL,
  ar VARCHAR(255) NOT NULL,
  arFile VARCHAR(255) NOT NULL,
  deployDur VARCHAR(255) NOT NULL,
  warmupDur VARCHAR(255) NOT NULL,
  scale VARCHAR(255) NOT NULL
)

SELECT *, ((0.0 + warmupDur) / deployDur) AS xwarmupSlower FROM ozizkaindata ORDER BY deployDur

投掷:

Caused by: org.hsqldb.HsqlException: duplicate column name in derived table
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.QuerySpecification.addSelectColumnExpression(Unknown Source)
    at org.hsqldb.ParserDQL.XreadSelect(Unknown Source)
    ...

SELECT ((0.0 + warmupDur) / deployDur) FROM ozizkaindata ORDER BY deployDur

抛出:

Caused by: java.lang.RuntimeException: unsupported internal operation: Type
    at org.hsqldb.error.Error.runtimeError(Unknown Source)
    at org.hsqldb.types.Type.divide(Unknown Source)
    at org.hsqldb.ExpressionArithmetic.getValue(Unknown Source)
    at org.hsqldb.QuerySpecification.buildResult(Unknown Source)
    at org.hsqldb.QuerySpecification.getSingleResult(Unknown Source)
    at org.hsqldb.QuerySpecification.getResult(Unknown Source)
    at org.hsqldb.StatementQuery.getResult(Unknown Source)

SELECT ((0.0 + CAST(warmupDur AS INT)) / CAST(deployDur AS INT)) AS xwarmupSlower FROM ozizkaindata

投掷:

Caused by: org.hsqldb.HsqlException: data exception: invalid character value for cast
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.Scanner.convertToNumber(Unknown Source)
    at org.hsqldb.types.NumberType.convertToType(Unknown Source)
    at org.hsqldb.types.Type.castToType(Unknown Source)
    at org.hsqldb.ExpressionOp.getValue(Unknown Source)
    at org.hsqldb.ExpressionArithmetic.getValue(Unknown Source)
    at org.hsqldb.ExpressionArithmetic.getValue(Unknown Source)
    at org.hsqldb.QuerySpecification.buildResult(Unknown Source)
    at org.hsqldb.QuerySpecification.getSingleResult(Unknown Source)
    at org.hsqldb.QuerySpecification.getResult(Unknown Source)

【问题讨论】:

【参考方案1】:

好吧,这很简单。 我忘记忽略带有注释的导入文本数据的第一行,所以它是无效的语法。 真可惜:)

【讨论】:

HSQLDB 2.0 "VALUES(1)" HSQLDB 1.8 "CREATE TABLE DUAL C INT" "INSERT INTO DUAL VALUES 0" "SELECT 1 FROM DUAL" Fredt@ 请在异常消息中包含列/表名...原因:org.hsqldb.HsqlException:数据异常:强制转换的字符值无效

以上是关于HSQLDB:重复的列名,不支持的内部操作:类型,强制转换字符无效的主要内容,如果未能解决你的问题,请参考以下文章

如何使用看起来像 HSQLDB 关键字的列名创建表?

查询重复列

小写的 HSQLDB 列名和表名

如何在 HSQLDB 中创建复杂的用户定义类型?

PHP MySQL内部连接具有相同的列名[重复]

HSQLDB UNIQUE 约束和 SQL 数组类型