Page 1 of 1

Random row selection

PostPosted: Wed May 16, 2012 1:24 pm
by rakesh086
i want to fetch a specific row from a file. like 150th row only.
how i can go ahead with cobol.

Re: Random row selection

PostPosted: Wed May 16, 2012 2:30 pm
by enrico-sorichetti
files do not have rows, they HAVE RECORDS
did You think about reading, incrementing a counter and stop when the counter reaches 150 ???

Re: Random row selection

PostPosted: Wed May 16, 2012 7:09 pm
by dick scherrer
Hello,

Why record 150?

What happens when the file content changes (adds / deletes)?

Re: Random row selection

PostPosted: Wed May 16, 2012 8:49 pm
by Akatsukami
rakesh086 wrote:i want to fetch a specific row from a file. like 150th row only.
how i can go ahead with cobol.

The real question is, what kind of data set are you reading?

As Dr. Sorichetti indicates, a sequential data set must be read sequentially; reading record 150 involves reading and discarding records 1-149. A relative data set can have a specific record read from it directly. The question is meaningless for an indexed data set, as key value, not position, is significant.

Tell us the organization of the data set, and you might get a useful answer.

Re: Random row selection

PostPosted: Sat May 19, 2012 8:30 am
by gokulNmf
Hi Rakesh,
If you know the record number (n) to read and if it is sequential then you have to read all the n-1 records.
If its a VSAM(KSDS,RRDS) you can use the key or RBA to find nth record.

Re: Random row selection

PostPosted: Sun May 27, 2012 12:24 am
by Pandora-Box
If the record number keeps changing and if you know it .

Suggest to pass it as a parm or control record

So you could read the Random number from Parm or control record and process it