UTL_FILE应用

Security Model

UTL_FILE is available for both client-side and server-side PL/SQL. Both the client (text I/O) and server implementations are subject to server-side file system permission checking.

....................

[@more@]

UTL_FILE应用

2007.09.18

Security Model

UTL_FILE is available for both client-side and server-side PL/SQL. Both the client (text I/O) and server implementations are subject to server-side file system permission checking.

In the past, accessible directories for the UTL_FILE functions were specified in the initialization file using the UTL_FILE_DIR parameter. However, UTL_FILE_DIR access is not recommended. It is recommended that you use the CREATE DIRECTORY feature, which replaces UTL_FILE_DIR. Directory objects offer more flexibility and granular control to the UTL_FILE application administrator, can be maintained dynamically (that is, without shutting down the database), and are consistent with other Oracle tools. CREATE DIRECTORY privilege is granted only to SYS and SYSTEM by default.

Note:

Use the CREATE DIRECTORY feature instead of UTL_FILE_DIR for directory access verification.

On UNIX systems, the owner of a file created by the FOPEN function is the owner of the shadow process running the instance. Normally, this owner is ORACLE. Files created using FOPEN are always writable and readable using the UTL_FILE subprograms, but non privileged users who need to read these files outside of PL/SQL may need access from a system administrator.

一、函数FOPEN

FOPEN Function

This function opens a file. You can specify the maximum line size and have a maximum of 50 files open simultaneously. See also FOPEN_NCHAR Function.

Syntax

UTL_FILE.FOPEN (

location IN VARCHAR2,

filename IN VARCHAR2,

open_mode IN VARCHAR2,

max_linesize IN BINARY_INTEGER)

RETURN file_type;

Parameters

Table 167-8 FOPEN Function Parameters

Parameter

Description

location

Directory location of file. This string is a directory object name and is case sensitive. The default is uppercase. Read privileges must be granted on this directory object for the UTL_FILE user to run FOPEN.

filename

File name, including extension (file type), without directory path. If a directory path is given as a part of the filename, it is ignored by FOPEN. On Unix, the filename cannot end with /.

open_mode

Specifies how the file is opened. Modes include:

r -- read text

w -- write text

a -- append text

rb -- read byte mode

wb -- write byte mode

ab -- append byte mode

If you try to open a file specifying 'a' or 'ab' for open_mode but the file does not exist, the file is created in write mode.

max_linesize

Maximum number of characters for each line, including the newline character, for this file (minimum value 1, maximum value 32767). If unspecified, Oracle supplies a default value of 1024.

Return Values

FOPEN returns a file handle, which must be passed to all subsequent procedures that operate on that file. The specific contents of the file handle are private to the UTL_FILE package, and individual components should not be referenced or changed by the UTL_FILE user.

Table 167-9 FOPEN Function Return Values

Return

Description

file_type

Handle to open file.

Usage Notes

The file location and file name parameters must be supplied to the FOPEN function as quoted strings so that the file location can be checked against the list of accessible directories as specified by the ALL_DIRECTORIES view of accessible directory objects.

Exceptions

INVALID_PATH: File location or name was invalid.

INVALID_MODE: The open_mode string was invalid.

INVALID_OPERATION: File could not be opened as requested.

INVALID_MAXLINESIZE: Specified max_linesize is too large or too small.

注:使用UTL_FILE.FOPEN出现“ORA-29280: invalid directory path”错误时,有以下几种原因

a、 指定的路径参数不存在;

b、 直接指定路径名,但数据库初始化参数文件中参数UTL_FILE_DIR不包含该路径;

c、 利用CREATE DIRECTORY创建目录后,用目录指定路径,但是未给用户该目录的读写权限。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7988176/viewspace-969937/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7988176/viewspace-969937/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值