Skip Headers

Oracle9i OLAP Developer's Guide to the OLAP DML
Release 2 (9.2)

Part Number A95298-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

Reading Data from Files, 3 of 9


Reading Files

While reading from a file, you can format the data from each field individually, and use DML functions to process the information before assigning it to a workspace object. Reading a file generally involves the following steps.

  1. Open the file you want to read.
  2. Read data from the file one record or line at a time.
  3. Process the data and assign it to one or more workspace objects.
  4. Close the file.

The FILEREAD and FILEVIEW commands have the same attributes and can do the same processing on your data. However, they differ in important ways:

Creating a Program to Read Data

The following table shows, for each method, the commands you need to open and close the input file, to read the file, and to handle errors that might occur.

Program Section

FILEREAD

FILEVIEW

Initialization

VARIABLE funit INTEGER
TRAP ON error
VARIABLE funit INTEGER
TRAP ON error

Body

funit = FILEOPEN(-
   'alias/datafile' READ)
FILEREAD funit 
   .
   .
   .
FILECLOSE funit
funit = FILEOPEN(-
   'alias/datafile' READ)
WHILE FILENEXT(funit)
   DO
   FILEVIEW funit . . .
   DOEND
FILECLOSE funit

Normal Exit

RETURN
RETURN

Abnormal Exit

error:
IF funit NE na
   THEN FILECLOSE funit
error:
IF funit NE na
   THEN FILECLOSE funit




Note:

The error handling in the abnormal exit section of the programs closes the file only when the file is open. The FILEOPEN function signals an error when for any reason the system cannot open the file. The program tries to close the file after the ERROR label only when FUNIT holds a valid file unit number. You can add additional commands to the error handling section as well. These sections of the program are the same for both methods.



Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2001, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback