32

First of all, this isn't a duplicate of this question. If it is, sorry but I couldn't solve my problem by reading it.

I'm getting this error:

ORA-00932: inconsistent datatypes: expected - got CLOB

When I try to execute this SELECT statement:

SELECT TXT.t_txt 
  FROM CITADM.tb_avu_txt_grc GR  
 INNER JOIN CITADM.tb_avu_txt TXT   
    ON (GR.e_txt = TXT.e_txt and GR.u_txt = TXT.u_txt)  
 WHERE  TXT.u_lin_ord = 1
UNION
SELECT TXT.t_txt 
  FROM CITADM.tb_avu_txt_grc_cvd GRC  
 INNER JOIN CITADM.tb_avu_txt TXT  
    ON (GRC.e_txt = TXT.e_txt and GRC.u_txt = TXT.u_txt)  
 WHERE  TXT.u_lin_ord = 2

The selected field(t_txt) is of CLOB datatype. As you can see, it's the same column of the same table. This statement belongs to a bigger one, I've isolated the part where I'm having this problem.

Thank you very much.

4

2 回答 2

62

我认为问题在于使用 ofUNION而不是UNION ALL. 操作员将合并这UNION两组并消除重复。由于无法比较 CLOB 类型,因此无法进行重复消除部分。

使用UNION ALL不会尝试进行重复消除(你可能没有重复)所以它应该可以工作。

于 2013-07-18T20:03:28.823 回答
-1

由于我重复,我不能使用 UNION ALL。该解决方案完美运行,谢谢!

顺便说一句:恕我直言,这是唯一正确的答案,因为 UNION ALL 和 UNION 在语义上是不同的。如果根本没有重复项,则使用 UNION 会带来不必要的排序开销。

于 2016-08-24T13:15:22.783 回答