View previous topic :: View next topic
|
Author |
Message |
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
how can i read nth (say 10th here) record in vsam ksds file? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Using ? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
using cobol.
and i dont know the key
but i know the position i.e. it is tenth record in the file. |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Read sequentially from the beginning 9 records and the next one is yours.
No magic. Or did I lost so much during my holiday? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
i want to reach directly to nth record not by reading it sequentialy.
is there any other way to do that? |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
With a KSDS and except if your key represents the sequence of the records, I cannot see a way to do it. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Even if you could directly read the nth record, what business need would it fill?
What happens when a few records are added or deleted and "that" record changes positon in the file?
If you explain the requirement, we may be able to offer suggestions.
Pierre,
Quote: |
Or did I lost so much during my holiday? |
No telling what may happen when you leave on holiday |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Dick,
there is huge file but specific chunk of data i . ae.
if rec 1 has value x then read from rec 1 to end
if rec 1 has value y then read from rec hm to rec m+value fetched from rec 1
if rec 1 has value z then read from rec hm to rec n+value fetched from rec 1
etc.
currently in production logic is implemented such that file is getting read sequentially keeping count of record and only records required are used using count.
so every time file is read till last record required from start.
I was thinking if it is possible to read first record and directly jump to required record no it will improve performance by lot. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I was thinking if it is possible to read first record and directly jump to required record |
Not that i'm aware of.
How does rec1 get built with these values x, y, z? If rec1 could be built using key values rather than numbers of records you should be able to accomplish what you need. |
|
Back to top |
|
|
revel
Active User
Joined: 05 Apr 2005 Posts: 135 Location: Bangalore/Chennai-INDIA
|
|
|
|
Hi Sambhaji,
You can do that by populating high values to the key fields of that file
ex;
consider a vsam file with structure
Code: |
01 emp-rec.
03 emp-id pic x(05) >>> key value
03 emp-name pic x(20).
03 emp-sal pic 9(4). |
After validating first record, simply populate High-values or X'FFFFF' to
key fields(ie emp-d). and read that record....
Just check it out and let me the result... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This silliness is yet another reason to migrate to db2. |
|
Back to top |
|
|
|