ORA-03113 and Getting CLOB Value from XMLTYPE

 

The Quest Code Tester for Oracle development team is making more and more extensive use of the XMLTYPE datatype in the Oracle database. XML documents are a perfect fit for several requirements of Code Tester, in particular storing values for nested structures like collections of records, which in turn contain collections as fields.

After adding an XMLTYPE column to our table, we then updated our table API packages to support retrieval of the XML document as a CLOB. You do this by invoking the GetClobVal method of the XMLTYPE object type.

Here's an example of the way we did this:

DECLARE
   l_clob   CLOB;
BEGIN
   SELECT qu_attributes.dp_value.getclobval ()
     INTO l_clob
     FROM qu_attributes
    WHERE parent_guid = 'a' AND usage_type = 'a';
END; 

Sadly, when I run this block of code on 11.2 (and we've seen in on 10g as well), I get the following error:

ORA-03113: end-of-file on communication channel

That is one nasty error! And, as any of you who have encountered ORA-03113 must know, this error does not identify a problem in our code. It reflects a bug of some sort in Oracle's code.

So the question that comes to mind immediately is: what's the workaround?

It looks like the problem has to do with executing this method inside the query. I moved the call to the method into its own function:

CREATE OR REPLACE FUNCTION gcv (xmltype_in IN XMLTYPE)
   RETURN CLOB
IS
BEGIN
   RETURN xmltype_in.getclobval ();
END;
/

and then I called the function in my query:

DECLARE
   l_clob   CLOB;
BEGIN
   SELECT gcv (qu_attributes.dp_value)
     INTO l_clob
     FROM qu_attributes
    WHERE parent_guid = 'a' AND usage_type = 'a';
END;

Then the ORA-03113 error disappeared. So that's the workaround, folks.

If you get an ORA-03113 in a query that works with XMLType columns, check to see if GetClobVal is being called and if so, move it out to a separate function and call the function from within the query.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值