- 论坛徽章:
- 0
|
我在ibm网站上找到了这个解决的方法,我把解决方法贴上来
int DataExport(char *dataFileName)
{
int rc = 0;
struct sqlca sqlca = {0};
struct sqldcol dataDescriptor = {0};
char actionString[256];
struct sqllob *pAction = {0};
char msgFileName[128];
struct db2ExportOut outputInfo = {0};
struct db2ExportStruct exportParmStruct = {0};
printf("\n-----------------------------------------------------------");
printf("\nUSE THE DB2 API:\n");
printf(" db2Export -- Export\n");
printf("TO EXPORT DATA TO A FILE.\n");
printf("\n Be sure to complete all table operations and release\n");
printf(" all locks before starting an export operation. This\n");
printf(" can be done by issuing a COMMIT after closing all\n");
printf(" cursors opened WITH HOLD, or by issuing a ROLLBACK.\n");
printf(" Please refer to the 'Administrative API Reference'\n");
printf(" for the details.\n");
/* export data */
dataDescriptor.dcolmeth = SQL_METH_D;
strcpy(actionString, "SELECT deptnumb, deptname FROM org");
pAction = (struct sqllob *)malloc(sizeof(sqluint32) +
sizeof(actionString) + 1);
pAction->length = strlen(actionString);
strcpy(pAction->data, actionString);
strcpy(msgFileName, "tbexport.MSG");
exportParmStruct.piDataFileName = dataFileName;
exportParmStruct.piLobPathList = NULL;
exportParmStruct.piLobFileList = NULL;
exportParmStruct.piDataDescriptor = &dataDescriptor;
exportParmStruct.piActionString = pAction;
exportParmStruct.piFileType = SQL_DEL;
exportParmStruct.piFileTypeMod = NULL;
exportParmStruct.piMsgFileName = msgFileName;
exportParmStruct.iCallerAction = SQLU_INITIAL;
exportParmStruct.poExportInfoOut = &outputInfo;
printf("\n Export data.\n");
printf(" client destination file name: %s\n", dataFileName);
printf(" action : %s\n", actionString);
printf(" client message file name : %s\n", msgFileName);
/* export data */
db2Export(db2Version820,
&exportParmStruct,
&sqlca);
DB2_API_CHECK("data -- export");
/* free memory allocated */
free(pAction);
/* display exported data */
rc = ExportedDataDisplay(dataFileName);
return 0;
} /* DataExport */
[[i] 本帖最后由 elegant 于 2006-4-14 17:05 编辑 [/i]] |
|