Skip Headers

Oracle® OLAP DML Reference
10g Release 1 (10.1)

Part Number B10339-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

FILEOPEN

The FILEOPEN function opens a file, assigns it a fileunit number (an arbitrary integer), and returns that number. You use the fileunit number, rather than a file name, in any further references to the file. When Oracle OLAP cannot open the file, an error occurs.

Return Value

INTEGER

Syntax

FILEOPEN(file-name {READ|WRITE|APPEND} [BINARY]) [NLS_CHARSET charset-exp]

Arguments

file-name

A text expression specifying the name of the file you want to open. Unless the file is in the current directory, you must include the name of the directory object in the name of the file.


Note:

Directory objects are defined in the database, and they control access to directories and file in those directories. You can use the CDA command to identify and specify a current directory object. Contact your Oracle DBA for access rights to a directory object where your database user name can read and write files.

READ

Opens the file for reading. (Abbreviated R)

WRITE

Opens the file for writing. File access begins at the top of the file. Therefore, opening an existing file in WRITE mode erases its contents completely even before anything is written to the file. (Abbreviated W)

APPEND

Opens the file for writing. File access begins at the end of the file, and data is added to the existing contents.

BINARY

Opens a binary-format file (a file with packed or binary data). When you specify BINARY, Oracle OLAP considers every character in the file to be data. Rather than using newline characters to tell when records end, it assumes records of a fixed length, which you can set with FILESET(...LSIZE). The default record length is 80.

NLS_CHARSET charset-exp

Specifies the character set that Oracle OLAP will use when reading data from the file specified by file-name. When this argument is omitted, then Oracle OLAP handles the data in the file as having the database character set, which is recorded in the NLS_LANG option.

Notes


Multiple File Units

You can open as many files at the same time as your operating system allows.


Access Modes

The mode of access, READ, WRITE, or APPEND, must be appropriate to the file.


OUTFILE Command

The OUTFILE command also opens a file and assigns an arbitrary integer as the fileunit number.


Case Sensitive File Names

When specifying a file name, be sure to match upper, lower, and mixed case exactly with the name of the file you want to open -- unless your operating system makes no case distinctions.

Examples

Example 13-2 FILEOPEN with an Argument Passed into a Program

The following line from a program opens a file whose name was specified as a program argument and saves the fileunit number in the variable fil.unit.

fil.unit = FILEOPEN(ARG(1), READ)

Example 13-3 FILEOPEN with a Binary File

The following statements open a binary file and set the record length.

VARIABLE filenum INTEGER
filenum = FILEOPEN('mydata' READ BINARY)
FILESET filenum LSIZE 132