Previous Topic

Next Topic

ChangeBatch

Change current batch (group of records).

Short Name

CHGBAT()

Type

ISAM function

Declaration

COUNT ChangeBatch(COUNT batchnum)

Description

ChangeBatch() is called before each use of DoBatch() when multiple batches are in use at the same time.

As a new batch area is needed, call ChangeBatch() with a unique batchnum. When ChangeBatch() perceives a previously unused batchnum value, AllocateBatch() is called to allocate the necessary batch structures for this new batchnum. These structures are not a concern of your program, but they are required for multiple, simultaneous batches.

Changing between active batches is accomplished by passing the desired batchnum value. batchnum values do not need to be consecutive and can be positive or negative values up to the maximum value of COUNT. See your compiler’s limits.h file for the maximum value of a 2-byte integer.

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful allocation.

185

ISAL_ERR

No memory available for set buffers.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

Example

#define namebuf 32

struct { /* data record format */
    TEXT name[namebuf];                     /* customer name */
    LONG num;                             /* customer number */
} parentimage;

COUNT error;
PKEYREQ  batsample;   /* batch partial key request structure */
TEXT     recbuf[1024];          /* batch retrieval structure */
TEXT     worktarget[namebuf];
COUNT    keyno;

memset(worktarget,' ',namebuf);
cpybuf(worktarget,"John",strlen("John"));
batsample.siglen = strlen(worktarget); cpybuf(batsample.target,worktarget,strlen(worktarget));

/* bufsiz for DoBatch is namebuf+ 4(long) + 4(record offset) */

if(ChangeBat(0) ||
      DoBatch(keyno,&batsample,recbuf, 40,BAT_GET|BAT_RET_REC))
    printf("\n\tError on BATSET - isam_err = %d",isam_err);
memset(worktarget,' ',namebuf);
cpybuf(worktarget,"Fred",strlen("Fred"));
batsample.siglen = strlen(worktarget);
cpybuf(batsample.target,worktarget,strlen(worktarget));

if (ChangeBat(1) ||
      DoBatch(keyno,&batsample,recbuf, 40,BAT_GET|BAT_RET_REC))
    printf("\n\tError on BATSET - isam_err = %d",isam_err);

ChangeBat(0);
DoBatch(keyno,NULL,NULL,0L,BAT_CAN);

ChangeBat(1);
DoBatch(keyno,NULL,NULL,0L,BAT_CAN);

See also

AllocateBatch(), FreeBatch(), DoBatch()