Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Reading blobs
I've been attempting to export data stored internally in the Oracle database
as a blob to a file. I've used the following code to insert the blob, and it
seems to run correctly:
declare
l_bfile bfile;
l_blob blob;
begin
insert into fa_templates values ( 3,'hi',6,'this is a test',empty_blob() )
return fa_template_data into l_blob;
l_bfile := bfilename( 'MY_FILES','A.TXT');
dbms_lob.loadfromfile(l_blob,l_bfile,dbms_lob.getlength(l_bfile) );
commit;
end;
I've selected the first field from the fa_templates file, and it appears as if the entry has been appended.
The problem occurs when I then try to retrieve the data. I've been using this code:
create or replace procedure test1 IS
file_handle utl_file.file_type;
l_lob blob; l_amt number default 30; l_off number default 1; l_raw raw(4096); l_var varchar2(5000);
loop dbms_lob.read( l_lob, l_amt, l_off, l_raw ); l_var := utl_raw.cast_to_varchar2( l_raw ); utl_file.put_line( file_handle, utl_raw.cast_to_varchar2( l_raw ) ); l_off := l_off + l_amt; l_amt := 4096; end loop; EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('no_data_found'); end;
WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('no_data_found'); UTL_FILE.FCLOSE(file_handle); WHEN UTL_FILE.INVALID_PATH THEN DBMS_OUTPUT.PUT_LINE('UTL_FILE.INVALID_PATH'); UTL_FILE.FCLOSE(file_handle); WHEN UTL_FILE.READ_ERROR THEN DBMS_OUTPUT.PUT_LINE(' UTL_FILE.READ_ERROR'); UTL_FILE.FCLOSE(file_handle); WHEN UTL_FILE.WRITE_ERROR THEN DBMS_OUTPUT.PUT_LINE('UTL_FILE.WRITE_ERROR'); UTL_FILE.FCLOSE(file_handle); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('other stuff'); UTL_FILE.FCLOSE(file_handle); END;
The procedure compiles without any problems. Unfortunately, when I execute it, I either get the 'no_data_found' or 'other stuff' error message.
Any help would be gratefully appreciated. Please cc replies to msherr_at_obs-us.com.
Thanks,
Micah
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Mon Aug 10 1998 - 15:53:22 CDT
![]() |
![]() |