How to delete particular row in the data set

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
DEVAPRIYA
Registered Member
Posts: 22
Joined: Fri Jul 18, 2014 5:30 pm

How to delete particular row in the data set

Post 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
Last edited by Anuj Dhawan on Fri Jul 18, 2014 9:25 pm, edited 1 time in total.
Reason: Moved the topic from "Polls and Ideas." It does not belong there.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: How to delete particular row in the data set

Post 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.
DEVAPRIYA
Registered Member
Posts: 22
Joined: Fri Jul 18, 2014 5:30 pm

Re: How to delete particular row in the data set

Post 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.
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to delete particular row in the data set

Post 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?
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
DEVAPRIYA
Registered Member
Posts: 22
Joined: Fri Jul 18, 2014 5:30 pm

Re: How to delete particular row in the data set

Post by DEVAPRIYA »

yes, i need to delete the particular record mnop 2 from dataset 1.
DEVAPRIYA
Registered Member
Posts: 22
Joined: Fri Jul 18, 2014 5:30 pm

Re: How to delete particular row in the data set

Post 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.
User avatar
Anuj Dhawan
Founder
Posts: 2799
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to delete particular row in the data set

Post 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.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”