熟悉COBOL和那个时代语言的人可能会记得以风格编写代码
While records exist in table A
Read a record from table A
If some condition
Read records in table B until match found
If some condition in record B
Read a record in table C
repeat ad nauseum
我们公司刚开始谈论将COBOL代码库更新为更现代化的东西,如果我们能够继续使用记录级访问权限,那么任何转换都会更容易,至少在转换过程中如此。用新语言重写所有内容和将所有内容转换为SQL可能太过分了。
是否有任何现代语言/数据库组合可以让我们对数据进行记录级访问?
答案 0 :(得分:0)
答案取决于您的具体情况。大多数现代语言都应提供某种形式的记录级访问。这是Python中的一个例子,假设数据文件是Cobol称之为“组织顺序”的。请注意,语法与您的示例没有太大区别。根据数据文件的结构,您可能需要使用tableB.seek(0)之类的东西来重新开始搜索文件。
tableA = open('tableA.txt', 'r')
tableB = open('tableB.txt', 'r')
tableC = open('tableC.txt', 'r')
for rowA in tableA:
if some_Condition():
for rowB in tableB:
if rowA_rowB_match():
if some_condition_in_record_B():
for rowC in tableC:
repeat ad nauseum
tableA.close()
tableB.close()
tableC.close()
def some_Condition():
if x:
return True
else:
return False
etc.