你能帮我在 Oracle 中使用 UTL 函数将表内容写入文件吗
在编写从表内容创建 CSV 文件的 SQL 过程时, 我陷入了以下错误:
ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation
ORA-06512: at "DSI_DPIPE.BUSSHOURS", line 28
ORA-06512: at "DSI_DPIPE.BUSSHOURS", line 55
ORA-06512: at line 1
第一行是:
file_http UTL_FILE.file_type;
即使我使用以下声明,也会出现相同的错误:
file_http sys.UTL_FILE.file_type;
感谢您提前提供宝贵的解决方案。
While writing the SQL procedure for creating a CSV file from the contents of the table,
I am stuck at the error below:
ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation
ORA-06512: at "DSI_DPIPE.BUSSHOURS", line 28
ORA-06512: at "DSI_DPIPE.BUSSHOURS", line 55
ORA-06512: at line 1
First line is:
file_http UTL_FILE.file_type;
Same error is coming even i am using the statement:
file_http sys.UTL_FILE.file_type;
Thanks for your valuable solution in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 CREATE DIRECTORY 功能而不是 UTL_FILE_DIR 进行目录访问验证。
UTL_FILE_DIR = * 是危险的,因为它允许有权访问 utl_file 包的数据库用户以用户 oracle 的权限读取/写入数据库服务器上的文件(datafiles、init.ora、listener.ora 等)。
您是否具有写入/读取该目录的正确权限。 服务器上的用户oracle需要读/写权限。
Use the CREATE DIRECTORY feature instead of UTL_FILE_DIR for directory access verification.
UTL_FILE_DIR = * is dangerous because is allows database users that have access to the utl_file package to read/write files on the database server with the permissions of the user oracle (datafiles,init.ora, listener.ora etc.).
Do you have the right permissions to write/read to the directory. User oracle on the server needs read/write permission.
oracle 用户是否具有在要放置文件的目录中写入的权限?
编辑:如果您在 Unix 环境中,您应该以 oracle 用户身份手动登录,转到您尝试创建文件的路径,然后使用命令“touch”创建一个文件。 如果你不能用这种方式创建文件,你就知道问题出在操作系统的“访问权限”上,否则问题出在ORACLE上。 (将减少 50% 的搜索;D)
编辑 2:
如果UTL_FILE_DIR = *,则数据库权限被禁用,所有文件和目录可供所有用户访问。 但我认为这仅适用于数据库级别,因此操作系统也有话要说。 如果oracle用户没有对某个目录的写权限,那么无论UTL_FILE_DIR怎么说,数据库的用户都无法获得此权限。
Has the oracle user access privileges for writing in the directory that you want to put the file?
EDIT: If you're in a Unix enviroment, you should manually login as the oracle user, go to the path that you're trying to create the file and use the command "touch" to create a file. If you can't create a file in this manner, you know that the problem is about "access privileges" in the operating sistem, else the problem is in ORACLE. (will reduce the search in 50% ;D )
EDIT 2:
If UTL_FILE_DIR = * then database permissions are disable and all files and directories are accessible to all user. But I think this applies only in a database level, so the operating system has also something to say. If the oracle user don't have a write access to some directory, then the users of the database can't adquire this right, no matter that UTL_FILE_DIR says.
检查目录路径是否正确以及您是否设置了正确的权限(即操作系统允许 Oracle 写入该位置)。
Check the directory path is correct and you have the right permissions set (i.e. Oracle is allowed by the operating system to write to that location).