My Oracle Support Banner

ORA-01706 with XMLTABLE and basing a VARCHAR2(4000) column on an XPath substring function (Doc ID 2375419.1)

Last updated on APRIL 12, 2022

Applies to:

Oracle Database - Enterprise Edition - Version and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.


A SQL query references an XML object in a CLOB column of a table and one of the columns in the XMLTABLE definition is MESSAGE_TEXT varchar2(4000) PATH 'substring(msgText,1,4000)'.  If the msgText value is in excess of 4000 characters, the SQL statement fails with ORA-01706.

SELECT m.message_text
FROM test_clob x, XMLTABLE('/chatTranscript/message'
PASSING xmltype(x.col_clob)
MESSAGE_TEXT varchar2(4000) PATH 'substring(msgText,1,4000)')
mSQL> SQL> 2 3 4 5
6 /
ORA-01706: user function result value was too large


This statement should not fail as the substring is taking the first 4000 characters.


To view full details, sign in with your My Oracle Support account.

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

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.