下面是我用来将数据从表中提取到平面文件的代码。
BEGIN
DECLARE
file_name VARCHAR2(50);
file_handle utl_file.file_type;
BEGIN
file_name := 'table.txt';
file_handle := utl_file.fopen('SEND',file_name,'W');
FOR rec in(
SELECT column 1
||'~'||column 2
||'~'||column 3 out_line
FROM table1)LOOP
UTL_FILE.PUT_LINE(file_handle,rec.out_line);
UTL_FILE.FFLUSH(file_handle);
END LOOP;
UTL_FILE.FCLOSE(file_handle);
END;
end;
此代码在我们的开发数据库中运行良好,但如果我在新数据库中执行,则会抛出以下错误。
Error starting at line 1 in command:
BEGIN
DECLARE
file_name VARCHAR2(50);
file_handle utl_file.file_type;
BEGIN
file_name := 'table.txt';
file_handle := utl_file.fopen('SEND',file_name,'W');
FOR rec in(
SELECT column 1
||'~'||column 2
||'~'||column 3 out_line
FROM table1)LOOP
UTL_FILE.PUT_LINE(file_handle,rec.out_line);
UTL_FILE.FFLUSH(file_handle);
END LOOP;
UTL_FILE.FCLOSE(file_handle);
END;
end;
Error report:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 7
29283. 00000 - "invalid file operation"
*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.
<小时/>
Oracle directory 'SEND' points to some UNIX directory which has rights as
'rwxrwsr-x' (Octal 2775)
Oracle Version:11g
请帮我解决这个问题。
如果您需要我提供更多数据来解决这个问题,请告诉我。
最佳答案
所以,@Vivek 通过评论中的对话而不是通过实际的答案找到了问题的解决方案。
"The file is being created by user
oracle
just noticed this in our development database. i'm getting this error because, the directory where i try to create the file doesn't have write access forothers
and useroracle
comes underothers
category. "
由于这个问题没有公认的答案,我提供了一个指向我关于 UTL_FILE.FOPEN()
主题的答案的链接。 Find it here .
附注我将此答案标记为社区 Wiki,因为它不是此问题的正确答案,只是重定向到其他地方。
关于oracle - ORA-29283 : invalid file operation ORA-06512: at "SYS.UTL_FILE", 行 536,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6014884/