Importing large character string using Text_io
8461Apr 19 2006 — edited Apr 20 2006Hi,
I have been using text_io and/or client_text_io on forms 10G, DB= 9i succesfully for a while to both read (parse) and write csv files. Today I ran across a problem. The csv file has two columns, one a short character string ( v_name varchar2(25)) and the other a character field that is usually less than 3000 characters but can be as high as 15000 characters (actually DNA sequences). Apparantly, the text_io is not working when this field is >~4000 characters. The database column that this is loading in to is a CLOB and the variable (v_seq) itself is set for varchar(15000) whereas the string (str) loaded with text_io.getline can be up to 32000 characters. The code below works fine If the second column in the csv is less than ~4000 characters. I tried to set the str and v_seq variables to CLOB but that did not run at all. Can anybody tell me how I can load longer character strings from csv files?
Thanks
Larry Solomon
DECLARE
file_name varchar2(100);
file1 TEXT_IO.FILE_TYPE;
str VARCHAR2(32000);
v_comma number;
v_comma2 number;
v_name varchar2(25);
v_seq varchar2(15000);
BEGIN
DEBUG.SUSPEND;
file_name := :control.orf_file_name;
file1 := client_TEXT_IO.FOPEN( file_name,'r' );
loop client_TEXT_IO.GET_LINE( file1, str );
v_comma := instr(str, ',');
v_name := substr(str,1, v_comma-1);
v_seq := substr(str,v_comma+1, length(str)-v_comma);
insert into ibase( name, orf)
values ( v_name, v_seq);
END LOOP ;
client_TEXT_IO.FCLOSE( file1 );
commit;