ora:contains Only Finds Search Hits Before Position 4000 in the XML Document (Doc ID 1276569.1)

Last updated on DECEMBER 27, 2010

Applies to:

Oracle Server - Enterprise Edition - Version: 11.1.0.7 and later   [Release: 11.1 and later ]
Information in this document applies to any platform.

Symptoms

On 11.1.0.7, 11.2.0.1 and 11.2.0.2 version, XML Database ora:contains function does not find the text_query string if this is after position 4000 in the XML document.

The issue can be reproduced at will with the following steps:

declare
c clob :=
''||
'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '||
'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '||
...
...
'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '||
'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '||
'test'||
'';
n number;
begin
select existsNode(xmltype(c),'a[ora:contains(text(),"test")>0]','xmlns:ora="http://xmlns.oracle.com/xdb"')
into n
from dual;
dbms_output.put_line('length(c)='||length(c));
dbms_output.put_line('n='||n);
end;
/

length(c)=4000
n=1 -- OK

length(c)=5000
n=0 -- Should be 1 !

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms