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

FILEGET

The FILEGET function returns text from a file that has been opened for reading. When FILEGET reaches the end of the file, it returns NA.

Return Value

TEXT

Syntax

FILEGET(fileunit [LENGTH intexpression])

Arguments

fileunit

A fileunit INTEGER assigned to a file opened for reading in a previous call to the FILEOPEN function.

LENGTH intexpression

An INTEGER expression specifying the number of bytes FILEGET should read from the file. When an end-of-line character is reached in the input file, FILEGET simply starts a new line in the result it is constructing. When LENGTH is omitted, FILEGET reads one line or record regardless of how many bytes it contains.

Notes


Binary Files

When you use the FILEGET function with a binary file, you will get an error.


TEXT, Not NTEXT

All text read with FILEGET is translated into the database character set. FILEGET cannot read data that cannot be represented in the database character set.

Examples

Example 12-15 Program for Reading a File

Suppose you have a program called readfile that takes a file name as its argument. It opens the file, reads the lines of the file, adds them to a multiline text variable named wholetext, then closes it. readfile uses local variables to store the fileunit number and each line of the file as it is read.

DEFINE wholetext VARIABLE TEXT
LD Multiline text variable
DEFINE readfile PROGRAM
LD Program to store data from a file in a multiline text variable
PROGRAM
VARIABLE fil.unit INTEGER  "Local Var To Store File Unit
VARIABLE fil.text TEXT     "Local Var To Store Single Lines
FIL.UNIT = FILEOPEN(ARG(1) READ)
FIL.TEXT = FILEGET(fil.unit)        "Read The First Line
WHILE fil.text NE NA                "Test For End-of-file
  DO
  wholetext = JOINLINES(wholetext, fil.text)
  fil.text = FILEGET(fil.unit)      "Read The Next Line
  DOEND
FILECLOSE fil.unit
END