Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dbms_lob.read - buffer problem

586714Jan 21 2009 — edited Jan 23 2009
Hi,

I have a file upload in Application Express which puts the file into a BLOB attribute of a table.
Then I use dbms_lob.convertToClob() to convert it into a CLOB and store it in a global variable g_clob.
Then I want to process the file/clob:
WHILE NOT std_lob.end_of_lob LOOP
 v_line := std_lob.get_line;
 v_line_nr := v_line_nr + 1;
 insert... etc.
END LOOP;
With smaller files (up to 32767 characters) it all works fine,
but with larger files I get "ORA-06502: PL/SQL: numeric or value error" in the end_of_lob function.
FUNCTION end_of_lob
	RETURN BOOLEAN
IS
	v_amount NUMBER;
	v_offset INTEGER :=1;
	v_buffer VARCHAR2(32767);
BEGIN
	v_amount := dbms_lob.getlength(g_clob);
	v_offset := g_position;
	dbms_lob.read(g_clob, v_amount, v_offset, v_buffer);
	RETURN FALSE;       -- end of CLOB is not reached
EXCEPTION
   /* no_data_found marks END OF LOB */
    WHEN no_data_found THEN
    RETURN TRUE;        -- end of CLOB is reached
    WHEN OTHERS THEN RAISE;
END end_of_lob;
I know the problem is that v_amount is larger than the buffer v_buffer which can't be increased.
Setting v_amount to a fixed size (eg. 10000) doesn't help.

How can that problem be solved?
I searched in this forum but didn't find a solution.

Any help is greatly appreciated.
Roger
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 20 2009
Added on Jan 21 2009
8 comments
6,395 views