我希望重新处理数据库中的350万条数据。我们使用的是Oracle PL/SQL 11g。我尝试每次获取1000行进行处理,但在处理了42000行后,它会抛出内存不足异常。 以下是我的代码:
internal void dataReprocessor(int rowCount)
{
DataTable dataTable = new DataTable();
int MaxProcessid = AssetProcessorDbHandler.GetMaxProcessId();
startCount=AssetProcessorDbHandler.GetErrorCount();
ShowStatus("Max. processid:" + MaxProcessid);
ShowStatus("Fetching " + rowCount + " rows....");
do
{
dataTable.Clear();
dataTable = AssetProcessorDbHandler.GetHundreadrows(rowCount, MaxProcessid);
if (dataTable.Rows.Count > 0)
{
for (int i = 0; i < dataTable.Rows.Count; i++)
{
int error = 0;
mainId = Convert.ToInt32(dataTable.Rows[i]["MAINID"]);
itemId = Convert.ToInt32(dataTable.Rows[i]["ITEMID"]);
siteid = Convert.ToInt32(dataTable.Rows[i]["SITE_ID"]);
equipmentId = Convert.ToInt32(dataTable.Rows[i]["EQUIPMENT_TYPE"]);
qrCode = dataTable.Rows[i]["QRCODE"].ToString();
string equipmentname = AssetProcessorDbHandler.Getequipmentname(equipmentId);
error = DbHandler.CheckQRCofEquipment(siteid, equipmentId, itemId, qrCode,ref assetStatus);
if (error == 1)//Not available in iMapp.
{
MESSAGE=string.Concat("QRCode ",qrCode," for ",equipmentname," is not available in iMapp!");
AssetProcessorDbHandler.UpdateSMSintoQRCtable(itemId, MESSAGE);
}
else if (error == 2)//Not available in that site.
{
int mappedsite = AssetProcessorDbHandler.Getmappedsiteid(qrCode);
MESSAGE = string.Concat("QRCode ", qrCode, " for ", equipmentname, " is mapped with site IN-", mappedsite);
AssetProcessorDbHandler.UpdateSMSintoQRCtable(itemId,MESSAGE);
}
else if (assetStatus == 1)//Equipment was in Finance verifiaction pending
{
MESSAGE = string.Concat("Finance verification pending of ", equipmentname, " for site IN-", siteid, " in iMapp. Please contact corporate finance team.");
AssetProcessorDbHandler.UpdateSMSintoQRCtable(itemId, MESSAGE);
}
AssetProcessorDbHandler.UpdateReprocessed(MaxProcessid + 1, itemId);
}
}
} while (dataTable.Rows.Count > 0);
ShowStatus("--Completed.--");
finalCount = AssetProcessorDbHandler.GetErrorCount();
ShowStatus(startCount + " ROWS PROCESSED.");
ShowStatus(finalCount + " ROWS ARE STILL ON ERROR.");
}
请有人帮忙吗?这个问题正在升级。
DataTable
时所使用的方法。 - Vikhram