ctsqlNextBatchItem
Move to the next batch item.
Declaration
INTEGER ctsqlNextBatchItem(pCTSQLCMD hCmd)
Description
ctsqlNextBatchItem() moves to the next item in a batch.
This function must be used with ctsqlPrepareBatch(). Below is an example inserting a batch of 45 records:
int batchSize=45;
if ((eRet = ctsqlPrepareBatch(hCmd, CT_STRING_LITERAL("insert into tab250 values (?,'original')"), batchSize)) != CTSQLRET_OK)
{
Output("ctsqlPrepare (%d)\n", eRet);
goto Exit;
}
for (i = 0; i < batchSize; i++)
{
if ((eRet = ctsqlSetIntegerParameter(hCmd,0,CTSQL_INTEGER,false,i)) != CTSQLRET_OK)
{
Output("ctsqlSetIntegerParameter (%d)\n", eRet);
goto Exit;
}
if ((eRet = ctsqlNextBatchItem(hCmd)) < 0)
{
Output("Batch is full\n"t);
goto Exit;
}
}
if ((eRet = ctsqlExecute(hCmd, &hCursor)) != CTSQLRET_OK)
{
Output("ctsqlExecute (%d)\n", eRet);
goto Exit;
}
Return
Returns batch item number (0 based). -1 if the batch buffer is full.