You are on page 1of 14

COmmon Business Oriented Language

1
File Processing

Indexed Files

2
Sequential Retrieval in RRDS
For Sequential retrieval in RRDS, the ACCESS should be sequential.

SELECT <vsamfile>
ASSIGN TO <ddname>
ORGANIZATION IS RELATIVE
ACCESS IS SEQUENTIAL
RELATIVE KEY IS RR-NUMBER

3
Direct Retrieval in RRDS
For direct retrieval in RRDS, the ACCESS should be Random.

SELECT <vsamfile>
ASSIGN TO <ddname>
ORGANIZATION IS RELATIVE
ACCESS IS RANDOM
RELATIVE KEY IS RR-NUMBER.

4
Sequential Retrieval in KSDS
For sequential retrieval in KSDS, the ACCESS should be Sequential.

SELECT <vsamfile>
ASSIGN TO <ddname>
ORGANIZATION IS INDEXED
ACCESS IS SEQUENTIAL
RECORD-KEY IS EMP-NUM
FILE-STATUS IS STATUS-KEY.

5
Direct Retrieval in KSDS
For direct retrieval in KSDS, the ACCESS should be Random.

SELECT <vsamfile>
ASSIGN TO <ddname>
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD-KEY IS EMP-NUM
FILE-STATUS IS STATUS-KEY.

6
READ STATEMENT - INDEXED
 For random access of data, the READ statement :

 Makes available a specific record from a mass storage file.

 For an invalid key, it performs the specified statement.

Syntax : READ file-name RECORD

[INTO data-name]

KEY IS key name

[INVALID KEY Imperative statement(s)]

NOT INVALID KEY Imperative statement(s)]

[END-READ].

Here is a sample code to demonstrate Read using a key .


7
Illustration to READ using a Key

8
Illustration to READ using a Key

9
WRITE STATEMENT - INDEXED

WRITE Record-name [FROM Data-name]

[INVALID KEY Imperative statement(s)]

[NOT INVALID KEY Imperative statement(s)]

[END-WRITE]
 Example :

WRITE REL-OUTPUT

INVALID KEY

GO TO ERROR-PARA.

10
REWRITE STATEMENT - INDEXED

 Used to replace a logical record for an output file whose key matches the
current content of the record key.
 The file must be opened in I-O mode.

Syntax :

REWRITE record-name [FROM data-name]

[INVALID KEY Imperative statement(s)]

[NOT INVALID KEY Imperative statement(s)]

[END-REWRITE].

11
START STATEMENT - INDEXED

 Enables the programmer to position the relative file at some specified point
by setting the current record pointer for later sequential processing.

Syntax :

START FILE-NAME

[KEY IS relational-operator Partial-record-key]

[INVALID KEY Imperative statement(s)]

[NOT INVALID KEY Imperative statement(s)]

[END-START].

12
DELETE STATEMENT - INDEXED

 Used to delete a record whose key matches the current contents of the record
key.

Syntax :

DELETE file-name [RECORD]

[INVALID KEY Imperative statement(s)]

[NOT INVALID Key Imperative statement(s)]

[END-DELETE].

13
Thank You

14

You might also like