|Oracle® OLAP DML Reference
10g Release 1 (10.1)
Part Number B10339-02
The FILENEXT function makes a record available for processing by the FILEVIEW command. It returns
YES when it was able to read a record and
NO when it reached the end of the file.
After reading a record with FILENEXT, use the FILEVIEW command to process the record. FILEVIEW processes input data and assigns the data to analytic workspace objects or local variables according to a description of each field. You can call FILEVIEW more than once for continued processing of the same record. To process another record, call FILENEXT again.
When all the records are being processed in essentially the same way, the FILEREAD command is easier to use because it loops over the records in a file automatically.
To write selected records to an output file, see the FILEPUT command.
Use the RECNO function to get the current record number for any file that is opened for read-only access.
When you did not specify BINARY for the file when you opened it, FILENEXT reads data up to and including the next newline character. When you specified BINARY for the file when you opened it, you must use FILESET to set LSIZE to the appropriate record length before using the FILENEXT function. Then, FILENEXT reads data one record at a time.
Example 13-1 Program That Uses FILENEXT
Suppose you receive monthly sales data in a file with the following record layout.
Column Width Format Data 1 1 Text Division code 2 10 Text District name 12 10 Text Product name 30 4 Packed binary Sales in dollars 34 4 Packed binary Sales in units
You want to process records only for your division, whose code is A. The following program excerpt opens the file, reads the lines of the file, determines if the data is for division A and, if so, reads the sales data, then closes the file. The file name is given as an argument on the statement line after the program name.
VARIABLE fil.unit INTEGER . . . fil.unit = FILEOPEN(arg(1) READ) LIMIT month TO &arg(2) WHILE FILENEXT(fil.unit) DO FILEVIEW fil.unit WIDTH 1 rectype IF rectype EQ 'A' THEN FILEVIEW fil.unit COLUMN 2 WIDTH 10 district - WIDTH 10 product - COLUMN 30 WIDTH 4 BINARY sales - WIDTH 4 BINARY UNITS DOEND FILECLOSE fil.unit