1 / 14

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

liam
Download Presentation

VSAM ACCESS METHODS

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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)

  2. 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

  3. 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)

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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.

  9. READ Statements Sequential Read by Primary Key READ file-name INTO file-layout AT END MOVE ‘Y’ to end-of-file switch.

  10. 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

  11. READ Statements Dynamic Read by Alternate Key 1) First read is a random read by alternate index 2) Subsequent reads is a sequential read

  12. 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

  13. 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.

  14. 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)

More Related