FairCom Corporation


F.12 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 Appendix A "c-tree Plus Error Codes" of the c-tree Plus Programmer's Reference Guide 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,worktar- get,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, and DoBatch.


FairCom Corporation
www.faircom.com