Utl_file.fopen usage of the utl_file package in Oracle

Source: Internet
Author: User

Utl_file.fopen in the utl_file package provided by Oracle is responsible for opening a file.

Utl_file.fopen (location in varchar2, filename in varchar2, open_mode in varchar2) return file_type;
Location is the path parameter,
Filename is the file name,
Open_mode is the open mode, 'R' is the read text, 'w' is the write text, and 'A' is the additional text. The parameter is case-insensitive. If 'A' is specified but the file does not exist, it is created with 'W', and 'w' has the overwriting function;

The location cannot be simply specified as a path such as 'd: \ Temp. You need to create a directory variable and pay the permission (you must Log On As A dBA ):

Create or replace directory d_output as 'd: \ Temp ';
Grant read, write on directory d_output to testdb;
Grant execute on utl_file to testdb;
Then you can use the utl_file package to create a file.

V_file utl_file.file_type;
V_file: = utl_file.fopen ('d _ output', 'data.txt ', 'w ');

You can create data.txt on the database server's D: \ temp.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.