skip to main content
Designing and coding the IP : Bulk insert : Bulk insert processing in Java
 

Bulk insert processing in Java

For performing bulk insert, the ipExecute method gets called with the statement type DAM_INSERT_BULK.
To process the bulk insert statement:
1. Use dam_getFirstInsertRow to obtain the row that has the bulk information.
2. Navigate through the columns of the row using dam_getFirstValueSet and dam_getNextValueSet.
3. Pass each row element (DAM_HROWELEM) that is returned by dam_getFirstValueSet and dam_getNextValueSet to dam_getBulkValueToSet.
Use dam_getColToSet to obtain details about the column.
4. Call dam_getBulkValueToSet(long hstmt, long hRowElem, xo_long iRowCount) that returns an array of objects of the Object data type (bulk information) for the specified row element handle and the row count object with the number of rows to be inserted.
You must save the array of objects of the Object data type.
5. For each row, based on the bulk information returned, retrieve the column values from object array and build the rows. You must index the array to obtain the column values.
6. Insert rows to the data source and mark the row insert status of each row using the byte array returned by dam_getBulkRowStatusArray.
If a row is inserted successfully, its status is marked as DAM_ROW_SUCCESS. If the row is not inserted successfully, the status is marked as DAM_ROW_ERROR.
7. Use dam_freeBulkValue to free the object array returned by dam_getBulkValueToSet.
Refer to DataDirect OpenAccess SDK™ SQL Engine Programmer’s Reference for Java® for more information.