ODBC Driver for ADP

Build 24.0.9060

Batch Processing

The CData ODBC Driver for ADP offers bulk load support in ADP through the ODBC Batch API. The driver can execute related SQL data manipulation statements simultaneously by translating them into a single bulk API request. In your application's code, the driver executes statements based on an array of inputs and a parameterized query.

Batch Update Procedure

Complete the following steps to execute a batch update:

  1. Define arrays of column values for each parameter in the statement.
  2. Set the SQL_ATTR_PARAMSET_SIZE statement attribute.
  3. Bind each array to each parameter.
  4. Execute the parameterized statement.

Bulk Insert

The following code shows how to execute a bulk insert with SQLSetStmtAttr, SQLBindParameter, and SQLExecDirect:

SQLHSTMT pHstmt = NULL;
const int MAX_INSERT_COUNT = 2;
const int MAX_BUFFER_SIZE = 100;
char WorkerIDArray[MAX_INSERT_COUNT][MAX_BUFFER_SIZE] = { 0 };
SQLLEN cbWorkerIDArray[MAX_INSERT_COUNT] = { 0 };
...
retcode = SQLSetStmtAttr(pHstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)MAX_INSERT_COUNT, 0);
char *WorkerID1 = "Jon Doe", *WorkerID2 = "John";
cbWorkerIDArray[0] = strlen(WorkerID1);
cbWorkerIDArray[1] = strlen(WorkerID2);
memcpy(WorkerIDArray[0], WorkerID1, strlen(WorkerID1));
memcpy(WorkerIDArray[1], WorkerID2, strlen(WorkerID2));
retcode = SQLBindParameter(pHstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, WorkerIDArray, MAX_BUFFER_SIZE, cbWorkerIDArray);

retcode = SQLExecDirect(pHstmt, (SQLCHAR*) "INSERT INTO Workers (WorkerID) VALUES (?)", SQL_NTS); 

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060