当我从前端检索xml文件时,我尝试将来自xml的数据放入oracle表中的blob列。但我得到以下错误;
ORA-01465:十六进制数无效
前端他们发送二进制对象类型。
此处XML标记包含以下详细信息。
<Contents>MzEvMDcvMjAxNA0KMS4gRmluZCBhIHdheSB0byBzdG9wIHBvc3RiYWNrIGluIFRyZWUgR3JpZCBpbiBDYWhydCBPZiBBY2NvdW50cyBNb2R1bGUgLSBEb25lDQoyLiBJcyBEaXNidXJzZSBGb3JtdWxhIHNhbWUgYXMgRm9ybXVsYQ0KMDYvMDgvMjAxNA0KMS5DaGFuZ2UgRGViaXRDcmVkaXQgdG8gRGViaXRDcmVkaXROb3RlDQoyOS8wOC8yMDE0DQoxLlNhbGVzIC0gQXV0aGVudGljYXRpb24gcmVxdWlyZWQgZm9yIG1vcmUgb3B0aW9ucw0KMi5IaXN0b3J5IC0gT3B0aW9uIHRvIHZpZXcgaXRlbSBsaXN0DQozLkNhc2hUaWxsIC0gT3B0aW9uIHRvIHNwZWNpZnkgSW4vT3V0DQowMy8wOS8yMDE0DQooVG8gQ2FzaCBUaWxsKQ0KMS5BZGQgQ2xlYXIgQnV0dG9ucyB0byBidXR0b25zIHN0cmlwIC0gRG9uZQ0KMi5TZWFyY2ggbm90IHdvcmtpbmcNCjMuRG91YmxlIGNsaWNrIGZlYXR1cmUgdG8gaW5jcmFzZSBpdGVtcyAtIERvbmUNCjQuQWRkIENsZWFyICYgUmVtb3ZlIGJ1dHRvbiB0byBrZXkgcGFkIC0gRG9uZQ0KNS5HaXZlIGFuIG9wdGlvbiB0byBjaGFuZ2UgY29sb3IgYW5kIGltYWdlIGR5bmFtaWNhbGx5Lg0KNi5NYWtlIGRlZmFsdXQgdGhyZWUgYnV0dG9ucyBhIHJvdyAtIERvbmUNCjcuQXJyYW5nZSBCdXR0b25zDQowOS8wOS8yMDE0DQoxLk1vZGlmeSBNYXN0ZXIgVUkgYXMgZGlzY3Vzc2VkDQoyLkZpbmFsaXplIENhc2ggVGlsbCB0byBFRg0KMy5E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E0DQoxLiBDYXNodGlsbCBJc3N1ZQ0KMi4gU2hvcCBDbG9zZSBDYXNoVGlsbHMgbXVzdCBiZSBjbG9zZWQuIEFsbCB1c2VycyBtdXN0IGJlIGxvZ2dlZCBvdXQsIGFsbCBkYXRhIG11c3QgYmUgc3luY2VkLg0KMy4gRGF0YSBVcGxvYWQNCjQuIFJlbW92ZSBPQkpDRVQgd3JhcHBlciBpbiBwYXNzd29yZCBjaGFuZ2UgWE1MDQo1LiBDaGVjayB0ZXJtaW5hbCBvcGVycmF0b3JzIGluc2VydCBpbiBkYXRhIGRvd25sb2FkDQo2LiBTZXQgdG8gMTAgd2hlbiB1bmFibGUgdG8gY3JlYXRlIHNlc3Npb24NCjcuIHNhbWUgZ29lcyB0byBhcHByb3ZhbA0KMTUvMDkvMjAxNA0KMS4gU2hvdyBkaXNjdW50IHByZWNlbnRhZ2Ugb24gQmVmb3JlIEludm9pY2UgKERvY2tldCBEaXNjb3VudCwgT3ZlcnJpZGUgRGlzY291bnQpDQoyLiBJbnZvaWNlIHJldHVybiBhbW91bnQvSW52b2ljZSBEYXRlDQoyMi8xMC8yMDE0DQoxLiBEb2NrZXQgaGlzdG9yeSBwcmludGluZyAtIERvbmUNCjIuIGRvY2tldCBzY2FuIHNlYXJjaCB3aXRob3V0IHNlYXJjaCBidXR0b24gLSBEb25lDQozLiByZXR1cm4gYW1vdW50IG5vdCBjYWxjdWxhdGluZyBhZnRlciBzY2FuIC0gRG9uZQ0KNC4gY2xlYXIgdGV4dGJveCBhZnRlciBzY2FuIC0gRG9uZQ0KDQo=</Contents>
这个查询。我试图检索。
SELECT CONTENT
FROM XMLTABLE ('/OBJECT/CommonFileUpload/CommonFileUploadFileList/CommonFileUploadFile'
PASSING (SELECT XMLCOL FROM BIZZXE_V2_SCH.B)
COLUMNS CONTENT BLOB PATH 'Contents') T
这是我的示例目标表
CREATE TABLE "TEST"
( `"CONTENT" BLOB`
)
答案 0 :(得分:1)
当我们尝试将字符串放入BLOB字段时,Oracle抛出错误Contents
。我们需要先将它转换为二进制格式。我们可以使用UTL_RAW.CAST_TO_RAW()函数完成此操作。 Find out more
但是,这里有一个二进制编码的字符串表示。将它存储为BLOB没有意义。你应该做的是将它存储为CLOB;当前端查询Contents
按原样返回该字符串时,让它们对其进行解码。
对于记录,这是我用于从XMLType列中提取declare
vc varchar2(32767);
lb blob;
begin
select t.content
into vc
from b,
xmltable ('/OBJECT/CommonFileUpload/CommonFileUploadFileList/CommonFileUploadFile'
passing b.xmlcol
columns content clob path 'Contents') t;
lb := utl_raw.cast_to_raw(vc);
insert into tgt values (lb);
end;
/
元素并将其存储为BLOB的代码:
SQL> select * from tgt;
BCOL
----------------------------------------------------------------------------------------------------------------------------------------------------------------
4D7A45764D4463764D6A41784E41304B4D533467526D6C755A43426849486468655342306279427A64473977494842766333526959574E7249476C75494652795A57556752334A705A43427062694244
SQL>
结果如下:
{{1}}
不太有用。