NET/MASTER Network Control Language (NCL) Programmer's Guide
Working With KeySequenced Files in a UDB Pair
Working With Files
12–96 106160 Tandem Computers Incorporated
SAY Unexpected error
END /*select*/
DO WHILE &SYS.FILE.RC = 0
ASSIGN VARS=&field* FROM MDO=&rec.
DO &fno = 1 TO &SYS.VARCNT
SAY "Field "&fno" is "&field&fno
END /*do*/
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
SAY Unexpected error
END /*select*/
END /*do while*/
END get_records
/* ==================== CLOSE FILE ==================== */
close_file: PROCEDURE SHARE &custfile,&distfile,&id
/* Close UDB pair from NCL and NonStop NET/MASTER */
SAY "Closing "&custfile &distfile
FILE CLOSE ID=&id
SELECT &SYS.FILE.RC
WHEN 16 THEN SAY "16 Closed"
OTHERWISE
SAY Unexpected error
END /*select*/
INTCMD "UDBCTL CLOSE=("&custfile","&distfile")"
INTREAD
INTCONT
END close_file
Example—Updating Records In a UDB Pair
The following NCL procedure allows you to update records in a UDB pair:
zex1215n: PROCEDURE
/* Updates records in 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 ==================== */