Download presentation
Presentation is loading. Please wait.
Published byIwan Hermawan Modified over 6 years ago
1
Agenda Test next Week! SI or no SI? File Update Techniques – Review
2
File Access Techniques
3
Sequential Access Reads one record at a time
Reads records in keyed sequence or arrival sequence
4
Random Access Records are processed in some other order than the one in which they were physically written to the disk or indexed. A key field is looked up in an index, the address is retrieved and the record is accessed from the physical file using the address.
5
Dynamic Access Defined when a file will be used both randomly and sequentially
6
Due to Normalization Practices, we usually have more than one file in our databases.
7
Employee Database Employeepf Provinces K Emp No K Prov Cde Prov Cde
Foreign Key Empnotpf K Emp No K Note No
8
Defining a Sequential Access File
SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is SEQUENTIAL RECORD KEY is EXTERNALLY-DESCRIBED-KEY.
9
Defining a Random Access File
SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is RANDOM RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates).
10
Defining a Dynamic Access File
SELECT Employee-File ASSIGN to DATABASE-EMPPF ORGANIZATION is INDEXED ACCESS MODE is DYNAMIC RECORD KEY is EXTERNALLY-DESCRIBED-KEY (with duplicates).
11
Beware of File Status Code 95!
Need to add ‘WITH DUPLICATES’ to your select statement or your need to take it out!
12
Randomly Retrieve a Record using a Random Defined File
Update the Key Fields in the File. READ file-name INVALID KEY Perform invalid-logic NOT INVALID KEY Perform valid-logic END-READ.
13
Sequential Read using a Random Defined File?
14
Sequentially Read using a Random Defined Record
Make sure that ACCESS is DYNAMIC!! READ file-name NEXT RECORD AT END Perform perform end-of-file-logic END-READ.
15
Positioning the File Pointer
Used only with Sequentially defined files. Initialize the record key START file-name Key Condition INVALID KEY Perform Invalid-Logic NOT INVALID KEY Perform valid-logic END-START.
16
Other Random Access Verbs
17
REWRITE Updates a record in a file
File must be opened as I-O instead of input Record must be read first before rewrite REWRITE record-name (FROM variable-name) INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-REWRITE.
18
DELETE Deletes a record from a file File must be opened as I-O
The record must be read first DELETE file-name RECORD INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-DELETE.
19
WRITE Writes records to a file File must be opened as I-O or OUTPUT
WRITE record-name (FROM variable) INVALID KEY perform error-rtn NOT INVALID KEY perform continue-rtn END-WRITE.
20
CPCH13B
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.