NET/MASTER Network Control Language (NCL) Programmer's Guide

Working With KeySequenced Files in a UDB Pair
Working With Files
106160 Tandem Computers Incorporated 12–95
END close_file
END zex1213n
Example—Getting Records From a UDB Pair
The following NCL procedure gets records from a UDB pair and displays them on an
OCS window:
zex1214n: PROCEDURE
/* Reads records from a UDB pair */
IF &1 = "" OR &2 = "" THEN DO
SAY "Must enter two file names"
EXIT
END /*do*/
ELSE
&custfile = &1
&distfile = &2
&id = UDBPAIR
CALL open_file SHARE &custfile,&distfile,&id
CALL get_records SHARE &custfile,&distfile,&id
CALL close_file SHARE &custfile,&distfile,&id
EXIT
/* ==================== OPEN FILE ==================== */
open_file: PROCEDURE SHARE &custfile,&distfile,&id
/* Open UDB pair for NonStop NET/MASTER and NCL */
SAY "Opening "&custfile &distfile
INTCMD "UDBCTL OPEN=("&custfile","&distfile") ID="&id
INTREAD
INTCONT
FILE OPEN ID=&id FORMAT=MAPPED MAP=$NCL
SELECT &SYS.FILE.RC
WHEN 0 THEN SAY "0 Read-only access"
WHEN 4 THEN SAY "4 Read and write access"
WHEN 8 THEN SAY "8 Read, write, and delete access"
WHEN 12 THEN SAY "12 No access"
WHEN 16 THEN SAY "16 "&SYSMSG
OTHERWISE
SAY Unexpected error
END /*select*/
END open_file
/* ==================== GET RECORDS ==================== */
get_records: PROCEDURE SHARE &custfile,&distfile,&id
/* Get records from UDB pair and display them */
/* on OCS window */
ASSIGN MDO=&rec. MAP=$NCL
FILE GET OPT=SEQ MDO=&rec.
SELECT &SYS.FILE.RC
WHEN 0 THEN DO
SAY "0 Record retrieved"
SAY "Key is "&SYS.FILE.KEY
SAY "Path is "&SYS.FILE.PATH
END /*do*/
WHEN 4 THEN SAY "4 Record not found or EOF"
WHEN 8 THEN SAY "8 Error "&SYS.FILE.ERROR
WHEN 16 THEN SAY "16 "&SYSMSG
OTHERWISE