Batch Processing
The CData ODBC Driver for Oracle Service Cloud offers bulk load support in Oracle Service Cloud 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:
- Define arrays of column values for each parameter in the statement.
- Set the SQL_ATTR_PARAMSET_SIZE statement attribute.
- Bind each array to each parameter.
- Execute the parameterized statement.
Bulk Delete
An array of the primary keys of the records to delete must be specified. The following code shows how to execute a bulk delete with SQLSetStmtAttr, SQLBindParameter, and SQLExecDirect:
SQLHSTMT pHstmt = NULL;
const int MAX_DELETE_COUNT = 2;
const int MAX_BUFFER_SIZE = 100;
char IdArray[MAX_DELETE_COUNT][MAX_BUFFER_SIZE] = { 0 };
SQLLEN cbIdArray[MAX_DELETE_COUNT] = { 0 };
...
retcode = SQLSetStmtAttr(pHstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)MAX_DELETE_COUNT, 0);
char *Id1 = "Id1", *Id2 = "Id2";
cbIdArray[0] = strlen(Id1);
cbIdArray[1] = strlen(Id2);
memcpy(IdArray[0], Id1, strlen(Id1));
memcpy(IdArray[1], Id2, strlen(Id2));
retcode = SQLBindParameter(pHstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, IdArray, MAX_BUFFER_SIZE, cbIdArray);
retcode = SQLExecDirect(pHstmt, (SQLCHAR*) "DELETE FROM Accounts WHERE Id = ?", SQL_NTS);