|Oracle® OLAP DML Reference
10g Release 1 (10.1)
Part Number B10339-02
FILEGET(fileunit [LENGTH intexpression])
A fileunit INTEGER assigned to a file opened for reading in a previous call to the FILEOPEN function.
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.
When you use the FILEGET function with a binary file, you will get an error.
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.
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