Results of DBMS_LOB.SUBSTR are Different on 10.2.0.4 And 11.2.0.1/10.2.0.5 (Doc ID 1190753.1)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version: 10.2.0.5 and later   [Release: 10.2 and later ]
Information in this document applies to any platform.

Symptoms

DBMS_LOB.SUBSTR is behaving differently on 10.2.0.4 and 10.2.0.5 / 11.2.0.1 with multibyte database characterset (AL32UTF8 or UTF8).


set serveroutput on
declare

vClob CLOB := 'a';
vPart1 VARCHAR2(32767);

vPart2 VARCHAR2(32767);
vPart3 VARCHAR2(32767);
begin
dbms_lob.append( vClob, utl_raw.cast_to_varchar2('504F53706C6974416E777C503134357C73656E647C7C323031302D30382D31387C31353A31343A30377C5341507C5045537C'));
dbms_lob.append( vClob, utl_raw.cast_to_varchar2('7C49434F49533031397C4F72646572204C41303030333031303120686173206265656E207363686564756C6564204C6F6720'));
...
dbms_lob.append( vClob, utl_raw.cast_to_varchar2('656E207363686564756C65647C7C7C4C4130303033303130307C7C7C7C7C7C7C7C4C4130303033303130307C'));
dbms_output.put_line( 'dbms_lob.getlength(vClob)='||dbms_lob.getlength(vClob));
vPart1 := dbms_lob.substr(vClob, amount=>32767, offset=>1);
dbms_output.put_line( 'LengthPart1='||length(vPart1));
vPart2 := dbms_lob.substr(vClob, amount=>32767, offset=>length(vPart1)+1);
dbms_output.put_line( 'LengthPart2='||length(vPart2));
vPart3 := dbms_lob.substr(vClob, amount=>32767, offset=>length(vPart1)+length(vPart2)+1);
dbms_output.put_line( 'LengthPart3='||length(vPart3));
end;
/


E.g. the result is the following:
10.2.0.4:
--dbms_lob.getlength(vClob)=17845
--LengthPart1=8191
--LengthPart2=8191
--LengthPart3=1463

10.2.0.5 / 11.2.0.1:
dbms_lob.getlength(vClob)=17845
LengthPart1=8191
LengthPart2=17845
LengthPart3=

On 10.2.0.5 and 11.2.0.1 for Part 2 the complete "string" with 17845 is returned,
instead of 8191 as on 10.2.0.4.

Changes

applying patch set 10.2.0.5 on 10.2.0.4.

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