大型机COBOL db2删除程序 [英] Mainframe COBOL db2 delete program

查看:103
本文介绍了大型机COBOL db2删除程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

详细问题是我的下一个问题-请检查下面的链接

Detail question is my next question -- please check below link

在cobol中运行的DB2/Cursor程序

推荐答案

这应该是一个两步过程.首先确定要删除的记录,然后在第二步中删除这些记录.我认为,您将无法从正在获取的同一张表中删除记录,这就是为什么要执行两个步骤.

This should be a 2 step process. First identify the records that are to be deleted and then delete those records in the 2nd step. I think, you'll Not be able to delete the records from the same table you are fetching, that's why 2 steps.

第1步:

Select Concat(A.ClientId, A.PhoneNumber, A.Timestamp) from MyTable A
 Where Concat(A.ClientId, A.PhoneNumber, A.Timestamp)
Not IN (Select Concat(B.ClientId, B.PhoneNumber, Min(B.Timestamp))
    from MyTable B
    Group by B.ClientId, B.PhoneNumber);

第2步:

Delete from MyTable
 Where Concat(A.ClientId, A.PhoneNumber, A.Timestamp) IN (all the values you got from Step1);

您可以运行第1步,创建一个数据集以获取所有值,然后在第2步中使用该数据集.如果正在动态运行,则将执行剪切粘贴,否则必须使用SORT修改数据集才能创建查询出来.这将是步骤1和2中间的另一个步骤.

You can run step 1, create a dataset to get all the values and use that dataset in step 2. If you are running dynamic then a cut paste will do, else you'll have to modify the dataset using SORT to create a query out of it. That will be another Step in the middle of step 1 and 2.

.

这篇关于大型机COBOL db2删除程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆