- 最后登录
- 2015-7-31
- 在线时间
- 45 小时
- 威望
- 5
- 金钱
- 205
- 注册时间
- 2013-9-27
- 阅读权限
- 10
- 帖子
- 22
- 精华
- 1
- 积分
- 5
- UID
- 1252
|
1#
发表于 2013-12-25 15:27:56
|
查看: 11122 |
回复: 7
现象描述:
在做exp/imp,新库imp时发现1个视图异常(IMP-00041: Warning: object created with compilation warnings)
手工创建,创建不了,报:ORA-00932: inconsistent datatypes: expected - got CLOB
但是旧库是正常的。
新库(imp导入的库)环境:
$ uname -a
Linux 601cluster 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
SQL> select * from V$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
SQL> select action,comments from registry$history;
ACTION COMMENTS
------------------------------ -----------------
VIEW RECOMPILE view recompilation
UPGRADE Upgraded from 10.2.0.1.0
APPLY PSU 10.2.0.5.4
旧库(exp导出的库)环境:
$ uname -a
Linux pera205 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
SQL> select * from V$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
问题SQL如下:
SQL较长,为了可读性,减掉了许多,但是报错效果是一样的。
create or replace view xxxx01 as
select
distinct( k.KNOWLEDGE_ID),
k.AUTHORID,
(select WMSYS.WM_CONCAT(kwt.workbag_id)
from km_workbag_knowledge kwt where kwt.object_type = 3
and kwt.knowledge_id=k.knowledge_id) as topicID
from KM_Knowledge K
where
k.param4 = 2
and k.param5 = 0 and k.current_version='1'
order by k.knowledge_id
;
去掉含有distinct的列,可以创建成功,如下:
create or replace view xxxx02 as
select
k.AUTHORID,
(select WMSYS.WM_CONCAT(kwt.workbag_id)
from km_workbag_knowledge kwt where kwt.object_type = 3
and kwt.knowledge_id=k.knowledge_id) as topicID
from KM_Knowledge K
where
k.param4 = 2
and k.param5 = 0 and k.current_version='1'
order by k.knowledge_id
;
去掉有CLOB列也可以创建成功,如下:
create or replace view xxxx03 as
select
distinct( k.KNOWLEDGE_ID),
k.AUTHORID
from KM_Knowledge K
where
k.param4 = 2
and k.param5 = 0 and k.current_version='1'
order by k.knowledge_id
;
表中的数据:
SQL> select count(*) from km_workbag_knowledge;
COUNT(*)
----------
1536
SQL> select count(*) from KM_Knowledge;
COUNT(*)
----------
64449
单独执行以下SQL:
select WMSYS.WM_CONCAT(kwt.workbag_id)
from km_workbag_knowledge kwt,KM_Knowledge K where kwt.object_type = 3
and kwt.knowledge_id=k.knowledge_id
通过PL/SQL执行,从结果的显示来看,旧库中该结果并没有转换成CLOB型,新库转换成了CLOB
在旧库中执行以下SQL:
将后面字段手工变为CLOB
create or replace view xxxx04 as
select
distinct( k.KNOWLEDGE_ID),
k.AUTHORID,
to_clob(
(select WMSYS.WM_CONCAT(kwt.workbag_id)
from km_workbag_knowledge kwt where kwt.object_type = 3
and kwt.knowledge_id=k.knowledge_id)) as topicID
from KM_Knowledge K
where
k.param4 = 2
and k.param5 = 0 and k.current_version='1'
order by k.knowledge_id
;
同样报下面的错:
ORA-00932: 数据类型不一致: 应为 -, 但却获得 CLOB
结论:
1. 创建视图时,不能同时有distinct和clob列
2. WMSYS.WM_CONCAT函数在不同的版本结果类型不一样,具体哪些版本暂时不知道
问题:
1.上面结论是否正确
2.WMSYS.WM_CONCAT 函数还会在哪些版本里结果会变成CLOB
3.写完以上内容后发现衣钩大师早有警示:http://www.eygle.com/archives/2012/10/wmsys_wm_concat.html 只是只列出了11.2.0.3 和10.2.0.5 ,是不是在这之后版本都会变成CLOB
|
|