The Enable Bulk Load connection option specifies the method by which bulk data is loaded to a database. When the option is enabled, the driver uses database bulk load protocols. When not enabled, the driver uses standard parameter arrays.
You can load data from the bulk load data file into the target database through the DataDirect driver Setup dialog by selecting the Bulk tab and clicking Load Table. See the individual driver chapters of the drivers that support bulk load for a description of this procedure.
Your application can also load data from the bulk load data file into the target database using the using the DataDirect functions LoadTableFromFile (ANSI application) or LoadTableFromFileW (Unicode application). The application must first obtain driver connection handles and function pointers, as shown in the following example:
HDBC hdbc; HENV henv; void *driverHandle; HMODULE hmod; PLoadTableFromFile loadTableFromFile; char tableName[128]; char fileName[512]; char configFile[512]; char logFile[512]; char discardFile[512]; int errorTolerance; int warningTolerance; int loadStart; int loadCount; int readBufferSize;
/* Get the driver's connection handle from the DM. This handle must be used when calling directly into the driver.*/
rc = SQLGetInfo (hdbc, SQL_DRIVER_HDBC, &driverHandle, 0, NULL); if (rc != SQL_SUCCESS) { ODBC_error (henv, hdbc, SQL_NULL_HSTMT); EnvClose (henv, hdbc); exit (255); } /* Get the DM's shared library or DLL handle to the driver. */
Refer to "Sample Bulk Load Configuration File" in DataDirect Connect Series for ODBC Reference for a full description of these functions.
Use the BulkLoadBatchSize connection attribute to specify the number of rows the driver loads to the data source at a time when bulk loading data. Performance can be improved by increasing the number of rows the driver loads at a time because fewer network round trips are required. Be aware that increasing the number of rows that are loaded also causes the driver to consume more memory on the client.
A log file of events as well as a discard file that contains rows rejected during the load can be created during a bulk load operation. These files are configured through either the driver Setup dialog Bulk tab or the LoadTableFromFile function.
The discard file is in the same format as the bulk load data file. After fixing reported issues in the discard file, the bulk load can be reissued using the discard file as the bulk load data file.
Note: FOR SYBASE USERS: Additional database configuration is required for destination tables that do not have an index. See the "Persisting a Result Set as an XML Data File" section in your driver chapter for more information.
Note: FOR SALESFORCE USERS: In addition to bulk Insert, the Salesforce driver also supports bulk Delete, Update, and Upsert. This functionality is enabled with the SetBulkOperation function which is implemented in the driver. Refer to "DataDirect Bulk Load Functions" chapter of the DataDirect Connect Series for ODBC Reference for a full description of these functions.