VSAM question: can I read in reverse key sequence?
Quote:
> On Wednesday, 98/01/28, David Gascon wrote to All about "VSAM question: can
> I read" as follows:
> DG> I work on a PL1 application that runs on both the mainframe (MVS) and PC
> DG> (both OS2 & Windows/NT). The database we use on the PC is Btrieve; on
> DG> the mainframe it's VSAM (a KSDS).
> DG>
> DG> In the enhancement I'm working on now, while examining a given database
> DG> record, the program is required to look at the *previous* record in key
> DG> sequence, i.e., with the next *lower* key.
> DG>
> DG> With Btrieve this is no big deal, already have it worked out. However,
> DG> I've been unable to find any documentation to suggest that it can be
> DG> done with a VSAM dataset; and even more to the point, I have yet to find
> DG> any PL1 option or attribute by which it could be done.
> DG>
> DG> Yet it seems a reasonable enough task, & it's hard to believe that
> DG> venerable VSM hasn't caught up with the [upstart] PC databases in this
> DG> respect.
> How many solutions would you like?
> VSAM has been able to do this for over 20 years.
I think that's about how long since I've seen a new reference manual!
(Tried in vain to find one in BookManager, can't stand that thing!) My
PL1 Lang. Ref. doesn't mention it - but then, my most recent manuals are
for OS2 & NT compilers, & they don't tend to trouble about VSAM.
Quote:
> I'm not sure how fully you have stated what you are trying to do. You have
> not said whether you always need to move backwards through the dataset or
> sometimes backwards and sometimes forwards.
Keyed read to set position, then sequential reads forward until end of a
series is reached. However, under certain circumstances I have to look
backward, maybe after the keyed read, maybe after one of the sequentials
(at the look-back point, I don't necessarily know which).
Quote:
> Given that you use a direct read to set the position, simply declaring
> ENV(BKWD) will allow you to move backwards on all sequential reads. E.g.
> READ FILE(VSAMDS) INTO(Main_rec) KEY(Key_value);
> READ FILE(VSAMDS) INTO(Prev_rec);
> The above will read the record of the given key into Main_rec and its
> predecessor into Prev_rec.
> If you need to toggle between forward and backward sequence then you will
> need:
> to use assembler to toggle the forward/backward flags in RPL's;
> to use 2 PL/I files for the same physical dataset;
> to use an ESDS with an AIX and RBA pointers to forward and
> backward records (can you say HIDAM?).
I assume the above is an OR. The second option looks promising.
Quote:
> Be aware that a KSDS is really for the intellectually lazy. There are much
> slicker ways to access VSAM datasets using ESDS or RRDS clusters.
Intellectually lazy, or just under the deadline gun? In any event, this
application (quite large, *many* programs involved) has been using a
KSDS for a long time (16 or more years, pretty long in the
application-software game, I think), and I don't think I'm going to be
the one to revolutionize it!
Anyway, there's a possibility the product will quit the mainframe in the
next couple of years and use Btrieve exclusively, in which case the
question will be moot.
But with your tips, perhaps VSAM has a fighting chance, at least for the
short run. Thanks for the info!
Quote:
> Regards
> Dave
> <Team PL/I>
> * KWQ/2 1.2i * I have a 286... Can I park in the handicapped space?
Cheers,
David