plsql - Oracle BLOB - Undo tablespace and efficient writing to file -
please see pl/sql code block @ end of post
i writing pl/sql code extract files zip. i'm using "as_zip" package found @ http://technology.amis.nl/wp-content/uploads/2010/06/as_zip7.txt file names found in zip (as_zip.get_file_list) , extract ones blob (as_zip.get_file) written file using utl_file.
first question
far i've seen in monitoring, undo tablespace doesn't seem written during process wanted confirm others true...if i'm extracting contents of particular files blob written out file, undo tablespace impacted? every megabyte business uses on database they're charged need ways reduce our tablespaces if @ possible...
second question
in terms of writing blob out file, there more efficient ways how i've done it? first file (which happens largest @ 3.03gb) writes out file system nice , quick each subsequent file seems write out slower , slower. need free resources or allocate them differently or....
set serveroutput on declare zip_files as_zip.file_list; l_file utl_file.file_type; l_buffer raw (32767); l_amount binary_integer := 32767; l_pos integer; l_blob blob; l_blob_len integer; begin dbms_output.enable(1000000); zip_files := as_zip.get_file_list( 'my_dir', 'my_file.zip' ); in zip_files.first() .. zip_files.last loop ext_table_rec in (select location user_external_locations) loop -- check if there's match between what's in zip file , external table name if (instr(trim(lower(zip_files(i))),trim(lower(ext_table_rec.location || '__'))) > 0) dbms_output.put_line('match found on ' || zip_files(i) || ', ' || ext_table_rec.location || ' - processing...'); l_blob := as_zip.get_file('my_dir', 'my_file.zip', zip_files(i)); -- open destination file. note third parameter "wb" l_file := utl_file.fopen ('my_dir', ext_table_rec.location, 'wb'); l_blob_len := dbms_lob.getlength (l_blob); -- read chunks of blob , write them file until complete. l_pos := 1; while l_pos < l_blob_len loop dbms_lob.read (l_blob, l_amount, l_pos, l_buffer); utl_file.put_raw(l_file, l_buffer, false); l_pos := l_pos + l_amount; end loop; -- close file. utl_file.fclose (l_file); end if; end loop; end loop; end; / in case wondering, here's comes database information when log in:
oracle database 11g enterprise edition release 11.2.0.2.0 - 64bit production partitioning, real application clusters, automatic storage management, oracle label security, olap, data mining, oracle database vault , real application testing options edit 1
i've taken out exception when others block based on information found on oracle sites. now, process seems hang, not sure issue occurring...
undo lob segments managed differently normal undo hash table.. undo managed , stored part of lob column itself. pctversion paramater can specify how space set aside undo. value specified percentage value.
Comments
Post a Comment