"STARTING WITH ISN" Clause isn't working

Hi guys! I have 2 READ loops: the first READ loop reads 10 records in DESCENDING order and stores the ISN of the 10th record; the second READ should start reading the records from this ISN (this one has a STARTING WITH ISN clause). But this clause seems not to be working in the READ 2. I printed #ISN-START value after READ 1 and the ISNs of the records read in the READ 2, but the same 10 records read in READ 1 are being read in the READ 2 and I don’t understand why.

Could someone give me a little hand with this? Thanks in advance.

READ-1. READ MULTI-FETCH OF 300 FILE DESCENDING
BY SUPER FROM #SUPER-INI TO #SUPER-FIM
*
    ADD 1                      TO #COUNT
*
    IF #COUNT = 10
      #ISN-START := *ISN
      ESCAPE BOTTOM
    END-IF
END-READ
*
READ-2. READ MULTI-FETCH OF 300 FILE DESCENDING
BY SUPER FROM #SUPER-INI TO #SUPER-FIM
STARTING WITH ISN = #ISN-START
.....
END-READ

Hi,

I think is not posible to read by Superdiscriptor AND starting in this area by ISN.

Kind regards,
MTÖ

You are not reset COUNT so ISN-START will be the same after first set when count gets to 10…

Also. If you want to really continue from the record 10 then recognize you should store Starting value as well.

When doing a read logical the STARTING with ISN is within the starting Value. This is designed for restarting when a DE (or SUPER) has multiple ISNs with same value.

For Example: READ EMPLOYEES by NAME = ‘SMITH’ Starting with ISN #LASTISNPLUS1.

Hope this helps

BTW I don’t normally recommend doing Multifetch

More than 25. More than that gives marginal results and in your case actually hurts performance as you are asking ADABAS to read and return 300 records but only processing first 10…

This is from the ADABAS command reference manual. It is saying the same thing Gene said.

Rules for Reading Backward (Descending Option)

If the starting descriptor value specified in the value buffer is present in the logical read sequence, specifying:

■ an ISN of zero results in positioning to the last (highest) ISN with that descriptor value;

■ a non-zero ISN results in positioning to the highest ISN less than the specified ISN with that descriptor value, if such an ISN exists. Otherwise, positioning is to the last ISN of the next

lower descriptor value.

If the starting descriptor value specified in the value buffer is not present in the logical read sequence, positioning is always to the last ISN of the next lower descriptor value, regardless of the specified ISN.

Eugene is correct. To use STARTING WITH ISN you must also specify the descriptor. Your program would look like this:

READ-1. READ MULTI-FETCH OF 10 FILE DESCENDING
BY SUPER FROM #SUPER-INI TO #SUPER-FIM
*
    ADD 1                      TO #COUNT
*
    IF #COUNT = 10
      #ISN-START := *ISN
      #SUPER-FIM-2 = SUPER
      ESCAPE BOTTOM
    END-IF
END-READ
*
READ-2. READ MULTI-FETCH OF 300 FILE DESCENDING
BY SUPER FROM #SUPER-INI TO #SUPER-FIM-2
STARTING WITH ISN = #ISN-START
.....
END-READ

Also be aware that STARTING WITH ISN actually does not start with the ISN specified but with the next record. For example, if I had the following data:

RECORD SUPER    ISN
R1     ABC       10
R2     ABD       15
R3     ABD       25
R4     ABD       30
R5     ABE       12

and I did:

READ FILE BY SUPER FROM 'ABD' STARTING WITH ISN 25

The first record read would be R4. If I was reading in descending order:

READ FILE DESCENDING BY SUPER FROM 'ABD' STARTING WITH ISN 25

The first record read would be R2.

1 Like

I might recommend the changes highlighted below

1 Like

Why wouldn’t your second READ start from #SUPER-FIM-2? that’s the ending value from the first READ, right?

1 Like

Because there is an escape bottom out of the loop I am assuming that 1st read doesn’t get to FIM2….

The amount of 10 is just an axample… in the real case I read more than 600 records.

This is deviating from initial problem, so I have changed the Subject.

So let’s take your example of 600 records read.

If you don’t use Multifetch you would have 600 ADABAS calls. If you choose a Multifetch of 10 you would have 60 adabas calls, a 90% improvement. If we go to MF of 25 then we will have 24 Calls a 96% improvement (but only 6% better than 10). If we go to MF of 50 then we will have 12 calls, a 98% improvement (but on 2% better than 25).

So you can see this is the law of diminishing returns. I find going beyond 25 doesn’t give me much but requires larger buffers and may degrade performance if we end up reading more records than we need.

Just my own guideline….

1 Like

Because it is reading DESCENDING. The FROM key value still needs to precede the TO key value so we read TO #SUPER-FIM-2, but we are really starting from there and reading backwards.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.