On Fri, 24 Apr 2009 07:15:15 -0500, Chase, John <jch...@ussco.com> wrote:
>> -----Original Message----- >> From: IBM Mainframe Discussion List On Behalf Of John McKown >> >> [ snip ] >> . . .. Take a case in point. A programmer has two VSAM KSDS >> files. He is reading one file sequentially and wants to see in the >second >> file has as associated record in it (both files are keyed >identically). How >> to do that? I will grant that in the past, this was a "no brainer". >However, >> this "normal" (perhaps sub-normal?) programmer did it the "easy" way. >He >> read the first file sequentially. Then, for each record read, he did a >keyed >> read of the second file. The second file contained about 5% of the >number of >> records in the first file. So 95% of the time, the keyed read got a >"record >> not found" and, as a plus, ended up with its buffers flushed and >positioning >> lost. >> >> Of course the correct way to do this is to read each file sequentially >in >> parallel (they are in the same order due to using the "same" key >values), >> doing a "match merge" type operation. But that mindset seems, at least >> around here, to have disappeared. I did the "match merge" code to show >how >> to do it (with a dramatic reduction in CPU and elapsed time). The >programmer >> considered __that__ to be "too advanced" and "obscure". > >IBM already provides a program to do exactly that: ICETOOL. > >Syncsort provides a similar program. Don't know about CA-Sort. > >Why bother to reinvent that wheel? > > -jc- I simplified too much. The code was more like (pseudo-COBOL): read master-file perform until eof-on-master-file move master-key to second-key read second-file key second-key if record-not-found-second then .... do default processing else .... do processing based on data in second-file end-if read mater-file end-perform it is still "better" (personal opinion) to read both files sequential, matching the key values and doing the required processing. -- John ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html