Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to manage two OS Text files in UTL_FILE Package simultaneously?
Add exceptions section to procedure and you see where it fails...
You said nothing about a error message...
>
>
>
> Declare
>
> l_file_handle1 UTL_FILE.FILE_TYPE;
>
> l_file_handle2 UTL_FILE.FILE_TYPE;
>
> l_buffer1 VARCHAR2(4000);
> l_buffer2 VARCHAR2(4000);
>
>
> BEGIN
BEGIN
> l_file_handle1 := UTL_FILE.FOPEN('c:\Test\Result', 'System_Name.txt',
> 'r', 4000);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Unable to open file1');
END;
BEGIN
> l_file_handle2 := UTL_FILE.FOPEN('c:\Test\Result',
> 'Machine.txt', 'r', 4000);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Unable to open file2');
END;
> loop
>
> UTL_FILE.get_line(l_file_handle1,l_buffer1);
> UTL_FILE.get_line(l_file_handle2,l_buffer2);
BEGIN
> insert into test (Hostname,Machine) values(l_buffer1,l_buffer2);
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Unable to insert row in a table'||chr(10)||sqlerrm);
END;
> commit;
> end loop;
>
> exception
>
> when no_data_found then
>
> UTL_FILE.FCLOSE(l_file_handle1);
> UTL_FILE.FCLOSE(l_file_handle2);
>
> when others then
>
> if utl_file.is_open(l_file_handle1)
> then
> utl_file.fclose(l_file_handle1);
> end if;
>
> if utl_file.is_open(l_file_handle2)
> then
> utl_file.fclose(l_file_handle2);
> end if;
>
> end;
>
> /
-- TomekBReceived on Wed Apr 28 2004 - 05:35:59 CDT