UTL_FILE将数据写入文件时出错

时间:2015-04-19 19:40:55

标签: oracle plsql

队 下面是示例代码,同时尝试将数据从游标写入文件 -

我目前正在使用11g Express Edition

CTEST is the directory created  and empdata is the declaration variable.

SQL>  declare
  2      empData utl_file.file_type;
  3       BEGIN
  4       empData := UTL_FILE.FOPEN('CTEST','empdata.csv','W');
  5       for emp IN ( select table_name from user_tables) LOOP
  6        UTL_FILE.PUT_LINE(empData,emp.table_name);
  7      END LOOP;
  8       UTL_FILE.FCLOSE(empData);
  9      end;
 10  /
    empData utl_file.file_type;
            *
ERROR at line 2:
ORA-06550: line 2, column 13:
PLS-00201: identifier 'UTL_FILE' must be declared
ORA-06550: line 2, column 13:
PL/SQL: Item ignored
ORA-06550: line 4, column 6:
PLS-00320: the declaration of the type of this expression is incomplete or

1 个答案:

答案 0 :(得分:0)

好像你没有UTL_FILE的权限,

来自sys用户的

运行此命令,

GRANT EXECUTE ON UTL_FILE TO <username> ;