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–89
Examples of Working With
Key-Sequenced Files in a
UDB Pair
This subsection has six examples of NCL procedures that illustrate how to work with
UDB pairs (record structure is mapped). The examples show:
How to add records to the read-only file in a UDB pair (before the file is opened as
part of the UDB pair)
How to get records from the read-only file in a UDB pair (before the file is opened
as part of the UDB pair)
How to add records to a UDB pair
How to get records from a UDB pair
How to update records in a UDB pair
How to delete records in a UDB pair
Comments throughout each example describe how it works. The comments also
indicate whether you should specify one or two file names when you execute each
example.
Note Before executing each example, you should use the SHOW UDB command to ensure that UDBPAIR is
not being used as a UDB ID at your installation. If it is, edit the examples so that they use a different
UDB ID.
Example—Adding Records to the Read-Only File in a UDB Pair
The following NCL procedure adds four records to a key-sequenced file (before the
file is opened as the read-only file in a UDB pair). The NCL procedure obtains the
records by pausing and waiting for input typed in at the OCS command input line.
One line of input is regarded as one field in a record. Each record has four fields. The
NCL procedure also creates the file opened for read and write access in a UDB pair
(for use in subsequent examples).
zex1211n: PROCEDURE
/* Adds records to a mapped key-sequenced UDB, */
/* the distributed file in a UDB pair. Also, */
/* creates the customized file in a UDB pair. */
ON ERROR FLUSH
IF &1 = "" OR &2 = "" THEN DO
SAY "Must enter two file names"
FLUSH
END /*do*/
ELSE
&custfile = &1
&distfile = &2
&id = UDBPAIR
CALL create_file SHARE &custfile,&distfile,&id
CALL open_file SHARE &distfile,&id
CALL add_records SHARE &distfile,&id
CALL close_file SHARE &distfile,&id
EXIT
/* ==================== CREATE FILE ==================== */