How to interrupt a retrieve on a large database table

Tony Marston - 6th June 2000

The following proc will pause a retrieve every 'n' records, and ask the user whether to continue or stop. This provides the opportunity to interrupt a full table scan.

READCOUNT should be a component variable, it will be incremented each time a record is read.
READLIMIT is a value which may be hardcoded or provided from some other source.

The calling sequence is:

read

if ($status = 0)
    call CHK_READ_COUNT(readcount,readlimit)
endif

Here is the code for the proc itself:-

;-----------------------------------------------------------------------
; pause retrieve after a number of records
;-----------------------------------------------------------------------
params
   numeric  pio_read_count    : INOUT
   numeric  pi_read_limit     : IN
endparams

pio_read_count = pio_read_count + 1    ; increment count
if (pio_read_count%pi_read_limit = 0)  ; divide by limit & test remainder
   $1   = pio_read_count
   askmess/question $text("%%$1 records have been read - do you wish to continue?")
   if ($status = 0)
      release/e                        ; drop remainder of hitlist
      return(-1)
   endif
endif

return(0)

;-----------------------------------------------------------------------
; Name:            CHK_READ_COUNT
;
; Author:          Tony Marston
;
; Date:            20-06-99
;
; Current Version: 1.0.0
;
; Description:     Increment record count and pause after every
;                  N records, allowing the user either to stop
;                  at this point, or to continue.
;
; read_limit is obtained from the logicals section in the ASN file.
;
; Input Parameters:    read_limit
;                      read_count
;
; Output Parameters:   $status
;                      read_count
;
; Update History:
; Date     Updated By      Details
;

Tony Marston
6th June 2000

mailto:tony@tonymarston.net
mailto:TonyMarston@hotmail.com
http://www.tonymarston.net

counter