Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Example Use of DoBatchXtd()

The following pseudo-code shows a strategy for using DoBatchXtd retrievals from one file to load into another file with the same record format.

ULONG batmode;

LONG irq[8192];

pPKEYREQ pirq = (pPKEYREQ) irq;

COUNT retval;

CHGBAT(0);

batmode= BAT_GET | BAT_PHYS | BAT_RET_BLK | BAT_LOK_RED |

BAT_LOK_BLK | BAT_LOK_ONE;

/*

** start batch retrieval at current ISAM position. [Can start at any

** legitimate record offset.]

*/

irq[4] = GETCURP(src_datno);/* low order word */

irq[3] = ctGETHGH();/* high order word */

/*

** first batch [0] retrieval

*/

retval = BATSETX(src_datno,pirq,irq+5,

(VRLEN) sizeof(irq) - 5 * sizeof(LONG),batmode);

/*

** prepare batmode for subsequent retrievals

*/

batmode &= ~BAT_GET;

batmode |= BAT_NXT;

TRANBEG(ctTRANLOG);

do {

printf("\nstatus=%d tot=%ld avl=%ld ret=%ld nxthw=%lx nxtlw=%lx",

retval,irq[0],irq[1],irq[2],irq[3],irq[4]);

}

if (retval)

break;

/*

** switch to batch [1] for insertion

*/

CHGBAT(1);

if (BATSETX(dest_datno,pirq,0x1,

sizeof(irq) - 5 * sizeof(LONG),

BAT_INS | (batmode & (BAT_RET_REC | BAT_RET_BLK))))

{

printf("\nBATSETX BAT_INS: %d\n",isam_err);

break;

} else

printf("\nBATSETX BAT_INS: success");

CHGBAT(0);

retval = BATSETX(src_datno,pirq,irq + 5,

(VRLEN) sizeof(irq) - 5 * sizeof(LONG),

BAT_NXT /*batmode*/);

} while (1);

TRANEND(ctFREE);

CHGBAT(0);

BATSETX(src_datno,NULL,NULL,0,BAT_CAN);

CHGBAT(1);

BATSETX(dest_datno,NULL,NULL,0,BAT_CAN);

TOCIndex