Sokrates on Oracle

utl_file.fopen raises exception when file to be opened has more than one name

Posted by Matthias Rogel on 15. June 2011

On Unix, creating a hard link is just the same as giving a file another name.
I observed an interesting issue when using utl_file with hard links:

11.2.0.2.0 > create directory tmp as '/tmp';
Directory created.
11.2.0.2.0 > !echo hi > /tmp/t.txt
11.2.0.2.0 > declare
2 f utl_file.file_type;
3 l varchar2(100);
4 begin
5 f:= utl_file.fopen('TMP', 't.txt', 'r');
6 utl_file.get_line(f, l, 100);
7 utl_file.fclose(f);
8 dbms_output.put_line('line = "' || l || '"');
9 end;
10 /
line = "hi"
PL/SQL procedure successfully completed.

so far, so good

now:

11.2.0.2.0 > !ln /tmp/t.txt /tmp/another_name_for_t.txt
11.2.0.2.0 > /
declare
*
ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 5

utl_file.fopen throws exception when file to be opened has more than one name.
I wonder why

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: