Indexed File Processing - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Indexed File Processing

Description:

000008EDMISTEN JESSIE SA2000003400500. 000009ROBINSONELSENERAPRIL HR0750002045600 ... When the file is created, special information about the file is stored that ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 13
Provided by: busi254
Learn more at: http://www.nku.edu
Category:

less

Transcript and Presenter's Notes

Title: Indexed File Processing


1
Chapter 15
  • Indexed File Processing

2
EMPLOYEE.DATA file
000001SAKAGUCHI TORU
SA2500001000000 000002KOWOLONEK RANDY
SA1825001110050 000003KIM JIN
HR0715000120900 000004IQBAL JAVID
HR0455000090000 000005CETRULO AMY
9999999999999 000006PEACE
JENNIFER SA3000001100000 000007DAVIS
SCOTT HR0800000094500 000008EDMISTEN
JESSIE SA2000003400500 000009ROBINSONE
LSENERAPRIL HR0750002045600 000010BATTLES
JOHN HR0630000876250 000011REED
MARY HR0900002340200 000012EAT
ON NICK SA3325011011100
3
Creating an Indexed File
  • When the file is created, special information
    about the file is stored that allows direct
    record access based on the key

4
Creating an Indexed File
  • SELECT EMPLOYEE-FILE ASSIGN TO
    EMPLOYEE.DATA ACCESS IS SEQUENTIAL ORGANIZATIO
    N IS SEQUENTIAL.
  • SELECT EMPLOYEE-FILE ASSIGN TO
    EMPLOYEE.DATA ACCESS IS RANDOM ORGANIZATION
    IS INDEXED RECORD KEY IS EMPLOYEE-NUMBER.

5
Sample Code
IDENTIFICATION DIVISION. PROGRAM-ID.
CREATEIND. ENVIRONMENT DIVISION. INPUT-OUTPUT
SECTION. FILE-CONTROL. SELECT EMPLOYEE-FILE
ASSIGN TO EMPLOYEE.DATA
ORGANIZATION IS INDEXED RECORD KEY IS
EMPLOYEE-NUMBER. DATA DIVISION. FILE SECTION. FD
EMPLOYEE-FILE 01 EMPLOYEE-RECORD. 05
EMPLOYEE-NUMBER PIC X(6). 05
PIC X(45). PROCEDURE DIVISION. 000-CREATE-EMPLOYE
E-FILE. OPEN OUTPUT EMPLOYEE-FILE CLOSE
EMPLOYEE-FILE STOP RUN .
6
Indexed Files
  • The only way that you can identify the type of
    file being created is by inspecting the SELECT
    clause.
  • Your program cannot add two records with the same
    key value. The key field must be unique in the
    file.
  • The records must be in ascending order on the key
    field.
  • One of the advantages of indexed files is that
    you can process them either randomly or
    sequentially.

7
Adding records to an indexed file
  • See BUILD program

8
(No Transcript)
9
Processing an Indexed File
  • Your program can
  • Add records
  • WRITE record-name
  • Modify records
  • REWRITE record-name
  • Delete records
  • DELETE record-name

10
(No Transcript)
11
(No Transcript)
12
Dynamic File Processing
  • Your program can jump to a position somewhere
    in the file and then begin processing
    sequentially.
Write a Comment
User Comments (0)
About PowerShow.com