0

我必须使用utl_file.

这就是我所做的:

  1. 在远程 PC 中使用 Adminstrator+Users+ora_db 配置文件创建用户,在我的 PC 中创建具有相同角色的相同用户。

  2. 使用此管理员帐户运行 Oracle 服务

  3. 映射Windows下的远程目录

  4. 使用以下命令配置和访问文件:

create or replace directory REMOTE_LOG as '\\remote_shared_dir\log';

declare
    f   UTL_FILE.FILE_TYPE;
    line    VARCHAR2(32767) ;

begin

    BEGIN
      f := UTL_FILE.FOPEN('REMOTE_LOG','toto.txt','R',32764);
    EXCEPTION WHEN OTHERS THEN
      dbms_output.put_line('err '||sqlerrm);
    END;

    UTL_FILE.GET_LINE( f,  line );                
    UTL_FILE.FCLOSE( f ) ;                
end;

但它失败了:

[Error] Execution (7: 3): ORA-29282: invalid file ID
ORA-06512: at "SYS.UTL_FILE", line 735
ORA-06512: at line 13

当我删除异常处理程序时,我看到的是:

[Error] Execution (7: 3): ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 8

我究竟做错了什么?

4

0 回答 0