简体   繁体   English

使用DBMS_LOB时出错

[英]Error using DBMS_LOB

Below is my query: 以下是我的查询:

SELECT dbms_lob.compare(NVL(original_xmldoc,'Null'),NVL(update_xmldoc,'Null'))
FROM xml_files;

When I execute, I received an error: 执行时,我收到一个错误:

ORA-06553: PLS-306: wrong number or types of arguments in call to 'COMPARE'
06553. 00000 -  "PLS-%s: %s"

Is there something wrong with my syntax? 我的语法有问题吗?

regards, 问候,

Nelz Ki 内兹(Nelz Ki)

If your data types are CLOB then you can do: 如果您的数据类型为CLOB则可以执行以下操作:

SELECT DBMS_LOB.COMPARE(
         NVL( original_xmldoc, Empty_CLOB() ),
         NVL( updated_xmldoc,  Empty_CLOB() )
       )
FROM xml_files;

However, that probably wouldn't generate the error you are seeing so I am assuming that you are using XMLType datatypes: 但是,这可能不会产生您所看到的错误,因此我假设您使用的是XMLType数据类型:

SELECT DBMS_LOB.COMPARE(
         NVL( original_xmldoc.getClobVal(), Empty_CLOB() ),
         NVL( updated_xmldoc.getClobVal(),  Empty_CLOB() )
       )
FROM xml_files;

(You could use the magic string 'Null' , as per your example, instead of Empty_CLOB() but it seems to me more natural to compare against an empty string rather than a made up value - however, you know your data better than us so it might be appropriate the other way round.) (按照您的示例,您可以使用魔术字符串'Null'代替Empty_CLOB()但在我看来,与空字符串进行比较而不是与固定值进行比较-但是,您比我们更了解自己的数据因此反过来可能比较合适。)

From your previous questions your columns are XMLType, not CLOB: 在前面的问题中,您的列是XMLType,而不是CLOB:

create table xml_files(original_xmldoc xmltype, update_xmldoc xmltype);

SELECT dbms_lob.compare(NVL(original_xmldoc,'Null'),NVL(update_xmldoc,'Null'))
FROM xml_files;

ORA-06553: PLS-306: wrong number or types of arguments in call to 'COMPARE'

The dbms_lob.compare() function expects CLOBs (or BLOBs) or something that be implicitly converted to them. dbms_lob.compare()函数需要CLOB(或BLOB)或隐式转换为它们的东西。 XMLTypes cannot. XMLTypes不能。 So you need to explicitly convert them: 因此,您需要显式转换它们:

SELECT dbms_lob.compare(NVL(x.original_xmldoc.getclobval(),'Null'),
  NVL(x.update_xmldoc.getclobval(),'Null'))
FROM xml_files x;

But you're comparing your fixed string value against an XML document and that might get the wrong result, as you're doing linguistic comparison, essentially between the 'N' of that string and the '<' of an actual XML document. 但是,您正在将固定的字符串值与XML文档进行比较,这可能会导致错误的结果,因为在进行语言比较时,实际上是在该字符串的'N'与实际XML文档的'<'之间进行比较。 As MTO said, it's probably better to use empty_clob() instead of 'Null' - with a quick test they get the opposite results. 正如MTO所说,最好使用empty_clob()而不是'Null' empty_clob()通过快速测试,它们会得到相反的结果。 And NLS settings could potentially change the result of the fixed-string version - bad in itself. 而且NLS设置可能会更改固定字符串版本的结果-本身就很糟糕。

Arguably if you're only looking for the result to be zero (the same) or non-zero (different for any reason) then it doesn't matter, but it's still better for it to be correct. 可以说,如果您只希望结果为零(相同)或非零(由于任何原因而不同),那么这无关紧要,但最好还是要正确。 Maybe someone will look at the actual value later and not realise it's wrong. 也许有人稍后会查看实际值,却没有意识到这是错误的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 指定xsd文档的路径时出错。 [使用dbms_xmlschema] - Error specifying path for the xsd document. [using dbms_xmlschema] 使用dbms_xslprocessor.clob2file将XML写入文件时出现Oracle错误 - Oracle error when writing XML to a file using dbms_xslprocessor.clob2file PLSQL-dbms_network_acl_admin.create_acl错误 - PLSQL - dbms_network_acl_admin.create_acl error 将 XML 作为 CLOB 传递给 Oracle 会出现“ORA-22922:不存在的 LOB 值”错误 - Passing XML as a CLOB to Oracle gives me "ORA-22922: nonexistent LOB value" error PLSQL使用DBMS_XMLDOM解析XML文件 - PLSQL parse XML file using DBMS_XMLDOM ORA-03113使用dbms_xmlschema.registerschema时 - ORA-03113 when using dbms_xmlschema.registerschema 我在使用XMLAGG并获取ORA-22275时遇到问题:指定了无效的LOB定位器 - I'm having trouble using XMLAGG and getting ORA-22275: invalid LOB locator specified 如何使用DBMS_XMLDOM在XML中定义名称空间 - How to define namespace in XML using DBMS_XMLDOM 模式ORA-06512中的标记断言错误:zh-CN“ XDB.DBMS_XMLSCHEMA” - Error with tag assert in schema ORA-06512: en “XDB.DBMS_XMLSCHEMA” 在桌面应用程序的配置数据上使用SQLite(或任何DBMS)而不是XML有什么优势? - What are the advantages of using SQLite (or any DBMS) over XML for a desktop application's configuration data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM