i am trying to load a csv file into dbtable using DB2Load Api ,
i am getting unhandled exception, Accessvoilation Error at
db2load(version,paramstructure, sqlca )
my code as follows.
i am suspecting there is some thing paramstruct , can any one guide me.
Thanks in advance.
Regards.
DBinter.
int DB2BulkLoad::LoadIntoDbTable (char *dataFileName)
{
int rc = 0;
struct sqlca sqlca = {0};
struct db2LoadStruct paramStruct = {0};
struct db2LoadIn inputInfoStruct = {0};
struct db2LoadOut outputInfoStruct = {0};
struct sqlu_media_list mediaList = {0};
struct sqldcol dataDescriptor = {0};
char actionString[256];
struct sqlchar *pAction = {0};
char localMsgFileName[128];
strcpy(m_tableName,"");
strcat(m_tableName,"TEST_BULKLOAD");
sqluvqdp(m_tableName, SQLU_QUIESCEMODE_RESET_OWNED, NULL, &sqlca);
DB2_API_CHECK("tablespaces for table -- quiesce");
mediaList.media_type = SQLU_CLIENT_LOCATION;
mediaList.sessions = 1;
mediaList.target.location = new sqlu_location_entry[mediaList.sessions];
strcpy(mediaList.target.location->location_entry, dataFileName);
dataDescriptor.dcolmeth = SQL_METH_D;
strcpy(actionString, "INSERT INTO ");
strcat(actionString, m_tableName);
pAction = (struct sqlchar *)new char[sizeof(short) +
sizeof(actionString) + 1];
pAction->length = strlen(actionString);
strcpy(pAction->data, actionString);
strcpy(localMsgFileName, "tbload.MSG");
inputInfoStruct.piUseTablespace = NULL;
inputInfoStruct.iSavecount = 0; /* consistency points as
infrequently as possible */
inputInfoStruct.iRestartcount = 0; /* start at row 1 */
inputInfoStruct.iRowcount = 0; /* load all rows */
inputInfoStruct.iWarningcount = 0; /* don't stop for warnings */
inputInfoStruct.iDataBufferSize = 0; /* default data buffer size
*/
inputInfoStruct.iSortBufferSize = 0; /* def. warning buffer size
*/
inputInfoStruct.iHoldQuiesce = 0; /* don't hold the quiesce */
inputInfoStruct.iRestartphase = ' '; /* ignored anyway */
inputInfoStruct.iStatsOpt = SQLU_STATS_NONE; /* don't bother with them
*/
inputInfoStruct.iIndexingMode = SQLU_INX_AUTOSELECT;
inputInfoStruct.iCpuParallelism = 0;
inputInfoStruct.iNonrecoverable = SQLU_NON_RECOVERABLE_LOAD;
inputInfoStruct.iAccessLevel = SQLU_ALLOW_NO_ACCESS;
inputInfoStruct.iLockWithForce = SQLU_NO_FORCE;
inputInfoStruct.iSetIntegrityPending =
SQLU_SI_PENDING_CASCADE_DEFERRED;
/* Setup the parameter structure */
paramStruct.piSourceList = &mediaList;
paramStruct.piLobPathList = NULL;
paramStruct.piDataDescriptor = &dataDescriptor;
paramStruct.piActionString = pAction;
paramStruct.piFileType = SQL_DEL;
paramStruct.piFileTypeMod = NULL;
paramStruct.piLocalMsgFileName = localMsgFileName;
paramStruct.piTempFilesPath = NULL;
paramStruct.piVendorSortWorkPaths = NULL;
paramStruct.piCopyTargetList = NULL;
paramStruct.piNullIndicators = NULL;
paramStruct.piLoadInfoIn = &inputInfoStruct;
paramStruct.poLoadInfoOut = &outputInfoStruct;
paramStruct.piPartLoadInfoIn = NULL;
paramStruct.poPartLoadInfoOut = NULL;
paramStruct.iCallerAction = SQLU_INITIAL;
db2Load (db2Version900,¶mStruct, & sqlca );
DB2_API_CHECK("table -- load");
delete [] pAction;
return 0;
}


|