0

I was wondering how you go about using the Start statement in COBOL to position a file to find records in an input file that are duplicates/copies.

Im not sure if I am getting the syntax right. I'm trying to find all the duplicate records in an input file. I've tried several different ways, including putting an if statement, but nothing works

...also, I can't post code since the code is for an entity.

Any help appreciated

Edited by ejiroy

2
Contributors
1
Reply
28
Views
3 Years
Discussion Span
Last Post by rainbowstew
1

If you want to find duplicate records in a file, the easiest way to do that is to sort the file on whatever field(s) you want to check for duplicates, (or the whole record if that's what you're looking for), and then open it as a sequential file, and read it, and for each record read, save the contents (or key) to a working-storage field, and then check the next record read to see if it matches, and if it does, write the record to another file, or do something else to notify you that it was a duplicate. I think the start statement syntax is pretty much the same as the read syntax for indexed files, but to find duplicates, I think you will find the way I described to be easier and probably faster. That's the way I'd do it.

Edited by rainbowstew: updated

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.