【问题标题】:Oracle Error: inconsistent datatypesOracle 错误:不一致的数据类型
【发布时间】:2011-06-28 05:57:43
【问题描述】:

我在我的 ORACLE(10g) 数据库中使用以下查询。

SELECT * from student_table where student_no like '%STUDENT%' 相交 SELECT * from student_table where student_no in ('STUDENT1234','STUDENT5678')

我收到如下错误: java.sql.SQLSyntaxErrorException: ORA-00932: 不一致的数据类型:预期 - 得到 CLOB

知道如何解决这个错误吗?

【问题讨论】:

  • 知道,尽管有错误,这两者的交集只是第二个查询的结果,不是吗?至少我是这么认为的。我可能是错的,这不是第一次 :-)
  • @paxdiablo:你是对的。如果比较或字符串不同,则可以在 where 子句中使用“AND”而不是 INTERSECT。

标签: select oracle10g intersection ora-00932


【解决方案1】:

当结果集包含任何 LOB 时,您不能执行 INTERSECT。

但是,在这种情况下,您仍然不需要相交:

SELECT * from student_table
where student_no like '%STUDENT%'
and student_no in ('STUDENT1234','STUDENT5678');

而且,正如前面所指出的,在这个特定的例子中,第一个条件是多余的:

SELECT * from student_table where student_no in ('STUDENT1234','STUDENT5678');

【讨论】:

    【解决方案2】:

    我猜student_table 至少包含一列数据类型为 clob。

    那么你不应该select *,而只能是非 clob 列。

    【讨论】:

      猜你喜欢
      • 2014-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多