create table test_clob
(
id number,
text clob
);
insert into test_clob values
(2,'Hi This can be a value that is too much old');
select * from test_clob;
SET serveroutput ON;
DECLARE
vlength pls_integer;
text_cbl CLOB;
Var_temp1 VARCHAR2(1024);
starti number := 1;
offset number:= 1;
val pls_integer;
amt pls_integer := 0;
BEGIN
SELECT text INTO text_cbl FROM test_clob WHERE id = 2;
vlength := SYS.DBMS_lob.getlength(text_cbl);
WHILE(starti < vlength)
LOOP
val := sys.dbms_lob.instr(text_cbl,chr(32),offset);
amt := val - offset;
sys.dbms_lob.read(text_cbl,amt,starti,Var_temp1);
dbms_output.put_line(Var_temp1);
offset := val;
starti := val + 1;
END LOOP;
END;
答案 0 :(得分:0)
在某些时候会有行尾或文本没有空格ch(32)所以在那一点它返回val&lt; = 0所以val - offset返回一个负值到amt所以sys.dbms_lob 。读取超出范围的偏移值。保持检查行尾或文本,或者你可以把条件和条件一样,如果val&gt;偏移然后阅读。