错误码:-6105
错误内容:数据类型不匹配
SQL中将CLOB类型字段进行关联条件进行匹配
create table lob1(id number,name varchar2(10),content clob);
create table lob2(id number,name varchar2(10),content clob);
insert into lob1 values (1,'aa','asd');
insert into lob1 values (2,'bb','qwe');
insert into lob2 values (1,'AA','asd');
insert into lob2 values (2,'BB','zxc');
commit;
--问题SQL
select a.name,b.name
from lob1 a,lob2 b
where a.content = b.content;
执行失败(语句1)
-6105: 第3 行附近出现错误:
数据类型不匹配
1、修改参数COMPATIBLE_MODE=2,兼容Oracle
2、可以通过dbms_lob包中的方法对CLOB数据进行处理
--dbms_lob.compare方法可以比较两个LOB数据,返回一个结果值,0即相等
select a.name,b.name
from lob1 a,lob2 b
where dbms_lob.compare(a.content,b.content)=0;
--dbms_lob.substr指定偏移开始的指定长度,CLOB的返回值为VARCHAR2
select a.name,b.name
from lob1 a,lob2 b
where dbms_lob.substr(a.content) = dbms_lob.substr(b.content);
文章
阅读量
获赞