尝试将具有blob列的表中的数据插入到具有二进制xml列的表中
源表
desc "T24"."FBNK_ACCOUNT_CLOSED";
Name Null? Type
----------------------------------------- -------- ----------------------
------
RECID NOT NULL VARCHAR2(255)
XMLRECORD BLOB
目标表
SQL> desc "T24"."FBNK_ACCOUNT_CLOSED_TEMP";
Name Null? Type
----------------------------------------- -------- ----------------------
------
RECID NOT NULL VARCHAR2(255)
XMLRECORD XMLTYPE STORAGE BINARY
所以我试图插入数据如下,但它失败了
SQL> insert into "T24"."FBNK_ACCOUNT_CLOSED_TEMP" select RECID,XMLRECORD
from "T24"."FBNK_ACCOUNT_CLOSED" where rownum<10;
insert into "T24"."FBNK_ACCOUNT_CLOSED_TEMP" select RECID,XMLRECORD from
"T24"."FBNK_ACCOUNT_CLOSED" where rownum<10
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected - got BLOB
我关注的文件是oracle文件(Doc ID 1405457.1)
下面是oracle文档中的几行
“使用insert select as syntax将数据从scott.tb blob移动到存储为二进制XML的scott.po_bin XMLType表中
SQL> insert into po_bin select xmltype(bc, 873) from scott.tb;
1 row created.
SQL> select * from po_bin;
SYS_NC_ROWINFO$
----------------------------------------------------------------------------
----
<?xml version="1.0" encoding="US-ASCII"?>
<PurchaseOrder>
<Reference>ADAMS-20011127121040988PST</Reference>
<Actions>
<Action>
<User>SCOTT</User>
<Date>2002-03-31</Date>
</Action>
</Actions>
<Reject/>
...
...
"
尝试编辑代码,几乎没有改动仍然没有其他错误号
insert into "T24"."FBNK_ACCOUNT_CLOSED_TEMP" select recid,
xmltype(xmlrecord, 873) from "T24"."FBNK_ACCOUNT_CLOSED" where rownum<1000
*
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00210: expected '<' instead of '2'
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 283
ORA-06512: at line 1
此失败的原因是该表包含一些无效的XML数据。因此,当将数据插入XML二进制列时,某些行的验证失败。所以这个不能在这张桌子上完成。但根据oracle文档,我的步骤是正确的。