A 2000 octet length limit applies only to the sql engine. In Pl / sql, you can use the entire range up to 32767 (2 ^ 15-1).
Starting from 12c, the 2000 length limit was removed.
However, up to 12c there is a length limit in the sqlplus client that does not allow column sizes above 4000 (value for 11g2).
The following code works for 11g2 and later
var myid number; exec :myid := 1234; -- whatever DECLARE l_r RAW(32767); BEGIN select dbms_lob.substr ( my_report, 2000, 1 ) head into l_r from my_table where my_table.report_id = :myid ; l_r := UTL_RAW.COPIES ( l_r, 10 ); dbms_output.put_line ( 'id ' || :myid || ', len(l_r) = ' || utl_raw.length(l_r)); END; / show errors
... although this version requires 12c:
var myid number; exec :myid := 1234; -- whatever DECLARE l_r RAW(32767); BEGIN select dbms_lob.substr ( my_report, 32767, 1 ) head into l_r from my_table where my_table.report_id = :myid ; dbms_output.put_line ( 'id ' || :myid || ', len(l_r) = ' || utl_raw.length(l_r)); END; / show errors
source share