日期:2014-05-17  浏览次数:21016 次

错误:必须声明标识符 'UTL_FILE'
CREATE OR REPLACE PROCEDURE EMPLOYEE_REPORT(
  dir VARCHAR2, filename VARCHAR2) 
  IS
  file UTL_FILE.FILE_TYPE;
  CURSOR empc IS SELECT last_name, department_id, salary /*查出所有需要的信息*/
  FROM employees ORDER BY department_id;
  BEGIN
  file:= UTL_FILE.FOPEN (dir, filename, 'w');
--如果文件没打开则打开它
  IF NOT UTL_FILE.IS_OPEN(file) THEN  
file := UTL_FILE.FOPEN (dir, filename, 'w');
  END IF; 

  FOR emp_rec IN empc LOOP
  UTL_FILE.PUT_LINE (file, 'DEPARTMENT: ' || emp_rec.department_id);
  UTL_FILE.PUT_LINE (file,' EMPLOYEE: ' || 
  emp_rec.last_name ||
  ' earns: ' || emp_rec.salary);
  END LOOP;
  UTL_FILE.PUT_LINE(file,'*** END OF REPORT ***');
  UTL_FILE.FCLOSE (file);
EXCEPTION
 WHEN UTL_FILE.INVALID_FILEHANDLE THEN
  RAISE_APPLICATION_ERROR(-20001,'Invalid File.');
 WHEN UTL_FILE.WRITE_ERROR THEN
  RAISE_APPLICATION_ERROR (-20002, 'Unable to write to file');
END EMPLOYEE_REPORT;

提示::行 4 上出现错误: PLS-00201: 必须声明标识符 'UTL_FILE'
该怎么改啊

------解决方案--------------------
把UTL_FILE包的执行权限给这个用户。
------解决方案--------------------
当前用户没有UTL_FILE的使用权限