declare cursor c1(vid integer) is select * from vmware where id = vid for update; cursor c2(rsess integer) is select * from dir_results where id = rsess; c1rec c1%ROWTYPE; time_a timestamp; time_z timestamp; bsts boolean; rsess integer; ctx raw(64) := NULL; mtype varchar2(1000); fmat varchar2(1000); j integer; -- vloc varchar2(1000) := 'N:\ORADATA\VNLZ\DATAFILE'; vloc varchar2(1000) := 'R:\ORADATA\VNLZ'; begin dbms_output.put_line( 'Start at:' || systimestamp ); time_a := systimestamp; select s_umo_sess.nextval into rsess from dual; bsts := os_command.directory_listing(vloc || '\*.*', rsess, FALSE ); execute immediate 'create or replace directory vmware_load as ''' || vloc || ''''; --delete from vmware; --dbms_output.put_line( '. Deleted at:' || to_char(systimestamp - time_a) ); commit; for c2rec in c2(rsess) loop time_z := systimestamp; dbms_output.put_line('. Loading:' || c2rec.fname || '[' || c2rec.fsize || ']' || c2rec.file_type); -- load into database j := c2%ROWCOUNT; insert into vmware(id,core_file) values (j, ORDSYS.ORDSource(empty_blob(), NULL,NULL,NULL,SYSDATE,1) ); commit; open c1(j); fetch c1 into c1rec; close c1; begin c1rec.core_file.importFrom(ctx, mtype, fmat, 'file', 'VMWARE_LOAD', c2rec.fname ); commit; dbms_output.put_line(' . . Size:' || gl.img_size(dbms_lob.getlength(c1rec.core_file.localdata),'A')); dbms_output.put_line( ' . . Inserted at:' || to_char(systimestamp - time_z) ); exception when others then dbms_output.put_line(' . . Failed:' || c2rec.fname || '-' || c2rec.fsize || ':' || sqlerrm); end; end loop; delete from dir_results where id = rsess; dbms_output.put_line( 'Finish:' || to_char(systimestamp - time_a) ); commit; end; /