plsql CSV文件读写

时间:2017-04-06 07:07:35

标签: oracle plsql

// Active Directory server
$ldap_host = "CRAMSDCR01V.cloud4rain.local";

// connect to active directory
$ldap = ldap_connect($ldap_host);

我收到错误:

OWNER   SYS
DIRECTORY_NAME  ME
DIRECTORY_PATH  \\172.16.20.11\Mad\


begin

vSFile := utl_file.fopen('ME','20170405.csv','R');
IF utl_file.is_open(vSFile) THEN
LOOP

2 个答案:

答案 0 :(得分:0)

出现此类问题的原因是您对read没有writedirectory权限。

运行以下查询,看看您是否拥有readwrite权限:

 SELECT * 
      FROM all_tab_privs 
     WHERE table_name = 'your_directory name';      

如果您发现没有任何访问权限,则授予读写权限。

SQL>CREATE OR REPLACE DIRECTORY dir1 as '/opt/oracle/';

SQL>GRANT READ,WRITE on dir1 to <Required user>; (if you want to give access to particular user)
OR
SQL>GRANT READ,WRITE on dir1 to PUBLIC; (if you want to give access to all users then give access to public)

答案 1 :(得分:0)

您的错误确切地告诉您问题所在:

*Cause: An attempt was made to read from a file or directory that does not exist, or file or directory access was denied by the operating system.

以及如何解决问题:

*Action: Verify file and directory access privileges on the file system, and if reading, verify that the file exists.

所以你指定:

DIRECTORY_PATH \\172.16.20.11\Mad\

你能用你的oracle用户实际访问\\172.16.20.11\Mad\吗?

如果没有,则需要grant read, write on directory to user并检查用户对该路径的操作系统权限。

但也考虑做一个网络共享来驱动信件,而不是UNC路径。