Vsam access methods
Download
1 / 14

vsam access methods - PowerPoint PPT Presentation


  • 346 Views
  • Updated On :

VSAM ACCESS METHODS. Sequential Start at the beginning of the file and read the records in sequence by either a primary key or a foreign key (Alternate Index) Random Read a particular record from the file (usually by primary key) Dynamic

Related searches for vsam access methods

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'vsam access methods' - liam


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Vsam access methods
VSAM ACCESS METHODS

  • Sequential

    • Start at the beginning of the file and read the records in sequence by either a primary key or a foreign key (Alternate Index)

  • Random

    • Read a particular record from the file (usually by primary key)

  • Dynamic

    • Read a particular record from the file and then sequentially until a particular condition is reached. Commonly used with non-unique foreign keys (Alternate Index)


Select statements
SELECT Statements

Sequential Access -By primary key

SELECT file-name ASSIGN TO DA-jclname

ORGANIZATION IS INDEXED

ACCESS IS SEQUENTIAL

RECORD KEY is record-key

FILE STATUS is status-name.

Where record-key is in the 01 layout immediately under

FD for the file-name. The Primary Key

status-name is declared in working storage as

PIC XX. The file status line is optional


Select statements1
SELECT Statements

Sequential Access -By foreign key (alternate index)

SELECT file-name ASSIGN TO DA-jclname

ORGANIZATION IS INDEXED

ACCESS IS SEQUENTIAL

RECORD KEY is record-key

ALTERNATE KEY is ai-name WITH DUPLICATES

FILE STATUS is status-name.

Where ai-name is in the 01 layout immediately under the FD

for the filename

WITH DUPLICATES is used if alternate index is

nonunique (in the Define Alternate Index)


Select statements2
SELECT Statements

Random Access - by Primary Key

SELECT file-name ASSIGN TO DA-jclname

ORGANIZATION IS INDEXED

ACCESS IS RANDOM

RECORD KEY is record-key

FILE STATUS is status-name.

Change from sequential access:

ACCESS is SEQUENTIAL to ACCESS is RANDOM


Select statements3
SELECT Statements

Random Access - by Alternate Key

SELECT file-name ASSIGN TO DA-jclname

ORGANIZATION IS INDEXED

ACCESS IS RANDOM

RECORD KEY is record-key

ALTERNATE INDEX IS ai-name WITH DUPLICATES

FILE STATUS is status-name.

Change ACCESS is SEQUENTIAL to ACCESS is RANDOM


Select statements4
SELECT Statements

Dynamic Access - by Alternate Index

(can also be used with primary keys but generally is NOT)

SELECT file-name ASSIGN TO DA-jclname

ORGANIZATION IS INDEXED

ACCESS IS RANDOM

RECORD KEY is record-key

ALTERNATE INDEX IS ai-name WITH DUPLICATES

FILE STATUS is status-name.

Change: ACCESS is SEQUENTIAL to ACCESS is DYNAMIC


The start statement
The Start Statement

  • Used with sequential access by AI

  • Initialize the AI to spaces (PIC X) or zeros (PIC 9) to start reading the data file at the start by AI

  • Generally used immediately after the opens


The start statement1
The Start Statement

MOVE spaces/zeroes TO alternate key in FD

START file-name

KEY > alternate key in FD

For Example: Assume TEXT-COPY is the file name

The Alternate Key in the SELECT statement is AI-KEY

Then the START statement would be:

MOVE SPACES TO AI-KEY.

START TEXT-COPY

KEY > AI-KEY.


Read statements
READ Statements

Sequential Read by Primary Key

READ file-name INTO file-layout

AT END MOVE ‘Y’ to end-of-file switch.


Read statements1
READ Statements

RANDOM Read by Primary Key

MOVE something TO record-key.

READ file-name INTO file-layout

KEY IS record-key

INVALID KEY imperative statements

NOT INVALID KEY imperative statements

END-READ.

Invalid key/Not invalid key clauses are optional

Can be checked with status codes


Read statements2
READ Statements

Dynamic Read by Alternate Key

1) First read is a random read by alternate

index

2) Subsequent reads is a sequential read


Read statements3
READ Statements

RANDOM Read by Alternate Key

MOVE something TO record-key.

READ file-name INTO file-layout

KEY IS alternate-key

INVALID KEY imperative statements

NOT INVALID KEY imperative statements

END-READ.

Invalid key/Not invalid key clauses are optional

Can be checked with status codes


Read statements4
READ Statements

Dynamic Read (Sequential portion) by Alternate Key

READ file-name NEXT RECORD INTO file-layout

AT END MOVE ‘Y’ to end-of-file switch.


Jcl notes
JCL Notes

For any VSAM file

Previously created with IDAMS - DEFINE CLUSTER

//GO.JCLNAME DD DSN=clustername,DISP=SHR (or OLD)

For any VSAM file with ALTERNATE KEY clause in SELECT

//GO.JCLNAME DD DSN=clustername,DISP=SHR (or OLD)

//GO.JCLNAME1 DD DSN=pathname,DISP=SHR (or OLD)


ad