Page 1 of 1

How to delete particular row in the data set

Posted: Fri Jul 18, 2014 8:41 pm
by DEVAPRIYA
Hi,
I need to delete particular row in the data set
Ex
Xxxx A
Xxxx b
Xxxx c

I need to delete the row with record xxxx b and the changes need to remain in the same data set.i need a program to do this process can any one help me pls?

Thanks
Deva

Re: How to delete particular row in the data set

Posted: Fri Jul 18, 2014 8:53 pm
by Robert Sample
Terminology note: data bases have rows. data sets have records. they are not the same.

Assuming you are talking about a data set and not a data base, the first question is what kind of data set? If the data set is a VSAM KSDS then you can delete the record by deleting the key of that record. If the data set is sequential, you MUST copy the data set to another data set, omitting the record you do not want copied. You can then optionally copy the output back to the original data set.

Re: How to delete particular row in the data set

Posted: Mon Jul 21, 2014 3:56 pm
by DEVAPRIYA
let me come up with example of what my situation....
for example:
dataset 1 contain following records

abcd 1
efgh 2
ijkl 1
mnop 2

dataset 2
efgh 2

i need to compare the two dataset records if 2nd dataset value is find in the Ist dataset records then it
need to compare with next record if the next record contain value as 1 in the 6th column then goes to next
and the next record contain 2 in 6th column then that record need to be removed.

if this comparison possible by if else or any other methods.

Re: How to delete particular row in the data set

Posted: Mon Jul 21, 2014 4:37 pm
by Anuj Dhawan
DEVAPRIYA wrote:i need to compare the two dataset records if 2nd dataset value is find in the Ist dataset records then it
need to compare with next record if the next record contain value as 1 in the 6th column then goes to next
and the next record contain 2 in 6th column then that record need to be removed.
When you say "remove" (delete?)-- do you really mean to remove from the input file or you're okay if you write the "compared results" to another output file?

Re: How to delete particular row in the data set

Posted: Tue Jul 22, 2014 5:50 am
by DEVAPRIYA
yes, i need to delete the particular record mnop 2 from dataset 1.

Re: How to delete particular row in the data set

Posted: Tue Jul 22, 2014 6:02 am
by DEVAPRIYA
i like to add one more detail if dataset 1 contain another record
abcd 1
efgh 2
ijkl 1
mnop 2
qrst 2

only that mnop 2 need to be deleted next record should not be deleted.

Re: How to delete particular row in the data set

Posted: Tue Jul 22, 2014 11:06 am
by Anuj Dhawan
DEVAPRIYA wrote:yes, i need to delete the particular record mnop 2 from dataset 1.
If it is so -- STOP -- and think around the first post from Robert, where he said:
the first question is what kind of data set? If the data set is a VSAM KSDS then you can delete the record by deleting the key of that record. If the data set is sequential, you MUST copy the data set to another data set, omitting the record you do not want copied. You can then optionally copy the output back to the original data set.
Remember couple of things before you proceed for your solution:
  • 1. You CAN NOT delete the records from a sequential file. And keeping the inference from your posts in mind, so far -- you seem to talk about sequential files only and if that's true -- you are picking up a wrong choice to do what you want to do.

    This is not the way this works on zOS -- as I've indicated earlier and Robert has also said that if you want to remove (delete) records from a sequential data-set (QSAM) and you're thinking to use DELETE command (as an appropriate one) - you can not issue DELETE some-record for a QSAM, the system does not accept this (Why? That's the rule). One of the alternative is what Robert has said and I think that's most practical in your situation.

    2. If your files are VSAM (KSDS), you can issue DELETE however you need to tell us what kind of VSAM it is - as you can not "delete" records from ESDS too but there are ways to mark them delete.
So hold on and decide what you've with you and what is possible to do with that.