动态读取...记录无效密钥在 COBOL 中无法正常工作。如何修复它?

发布于 2024-10-30 02:41:04 字数 814 浏览 1 评论 0原文

具有文件控制功能的 Cobol 程序如下所示:

SELECT D-FLAT-FILE ASSIGN TO DFLAT-FILE
       ORGANIZATION IS INDEXED
       ACCESS MODE IS SEQUENTIAL 
       FILE STATUS IS RECORD-STAT
       RECORD KEY IS D_KEY OF D-FLAT-FILE DESCENDING WITH DUPLICATES.


SELECT C-MAST-FILE ASSIGN TO CMAST-FILE
       ORGANIZATION IS INDEXED
       ACCESS MODE IS DYNAMIC 
       FILE STATUS IS RECORD-STAT
       RECORD KEY IS C_KEY OF C-MAST-FILE.

从第一个平面文件中读取一条记录,如下所示:

PROCESSING.
    READ D-FLAT-FILE NEXT RECORD
        AT END ....END READ.

并在第二个动态文件上读取一条记录,如下所示:

READ C-MAST-FILE RECORD
     INVALID KEY
     GO TO PROCESSING.

除 1 种情况外,一切正常。如果第一个平面文件中的第一条记录与第二个动态文件中的任何记录都不匹配,则程序将进入无限循环,而不是执行“转到处理”。我检查了手册,全部按照手册进行(它是 VAX Cobol)。我缺少什么?

A Cobol program with file-control like so:

SELECT D-FLAT-FILE ASSIGN TO DFLAT-FILE
       ORGANIZATION IS INDEXED
       ACCESS MODE IS SEQUENTIAL 
       FILE STATUS IS RECORD-STAT
       RECORD KEY IS D_KEY OF D-FLAT-FILE DESCENDING WITH DUPLICATES.


SELECT C-MAST-FILE ASSIGN TO CMAST-FILE
       ORGANIZATION IS INDEXED
       ACCESS MODE IS DYNAMIC 
       FILE STATUS IS RECORD-STAT
       RECORD KEY IS C_KEY OF C-MAST-FILE.

reads a record from the first flat file like so:

PROCESSING.
    READ D-FLAT-FILE NEXT RECORD
        AT END ....END READ.

and reads a record on the second DYNAMIC file like so:

READ C-MAST-FILE RECORD
     INVALID KEY
     GO TO PROCESSING.

All works well except for 1 case. If the 1st record from the 1st flat file does not match any records on the 2nd dynamic file, the program goes into an infinite loop instead of doing GO TO PROCESSING. I checked the manuals, all as per manual (it is the VAX Cobol). What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

兲鉂ぱ嘚淚 2024-11-06 02:41:04

最佳实践是为每个文件使用不同的文件状态变量。就您而言,您没有向我们展示足够的背景来了解问题。但是,如果您正在循环查看 RECORD-STAT,那么从 C-MAST-FILE 读取失败可能会让您感到悲伤。

Best practice is to use a different FILE STATUS variable for each file. In your case you haven't shown us enough context to see the problem. But if you are in a loop looking at RECORD-STAT, then it is possible that the failed read from C-MAST-FILE is giving you grief.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文