Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

FreeBatchNbr

Free space allocated for a specific batch.

Short Name

FREBATN()

Type

Low-Level function

Declaration

COUNT FreeBatchNbr(COUNT batnum)

Description

FreeBatchNbr() frees batch number batnum. This routine permits flexible use of a large number of batches within particular code segments responsible for the creation and clean up of the particular batches. Instead of freeing all batches any time one batch needs to be freed, this function frees batches one at a time.

Return

This routine returns an error code, but should return NO_ERROR (0) even if the batnum given does not exist. See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

FILNO keyfil;

PKEYREQ batsamp; /* Partial Key Request structure */

TEXT recbuf(1024), retbuf(1024); /* buffers for records */


batsamp.siglen = 4; /* first 4 bytes significant */

sprintf(batsamp.target,"DISK"); /* partial key value */

ChangeBatch(PRIMARY);

if (DoBatch(keyfil,&batsamp,recbuf,1024,

BAT_GET | BAT_RET_REC | BAT_COMPLETE | BAT_LOK_WRT)) {

printf("\nBatch error %d",isam_err);

return;

}

printf("\n%ld entries match",batsamp.btotal);


/* find info in batch */

if ((retbuf = find_in_batch(&recbuf, 1024)) != NULL) {

ChangeBatch(SECONDARY)

if (DoBatch(keyfil,&batsamp,retbuf,1024,

BAT_GET | BAT_RET_REC | BAT_COMPLETE | BAT_LOK_WRT))

{

printf("\nSecondary batch error %d",isam_err);

return;

}

printf("\n%ld entries match",batsamp.btotal);

DoBatch(keyfil,NULL,NULL,0L,BAT_CAN); /* close the batch */

FreeBatchNbr(SECONDARY);

ChangeBatch(PRIMARY);

}

DoBatch(keyfil,NULL,NULL,0L,BAT_CAN); /* close the batch */

FreeBatch();

See also

DoBatch(), FreeBatch(), ChangeBatch()

TOCIndex