偶
偶尔幽默
Unregistered / Unconfirmed
GUEST, unregistred user!
用ODBC连接,ORACLE数据库。Delhpi中创建TABLE,然后把查询的数据添加到TABLE表中,<br>由于数据量太大(87万),所以当TABLE中添加了20万条记录时,就再创建一TABLE, 以此类推。问题:当循环到457856条记录执行NEXT操作时报 'temporary table resource limit'错误,请问该如何解决。源码如下:<br>Function Tf_main.SaveQueryToTable(aQuery:TQuery;xh:Integer;SourceTableName,destTableName:String):Boolean;<br>var<br> i,rno,tcount:Integer;<br> tmpdb,tmpname:string;<br> msg:TMsg;<br> tmpstr:String;<br> j,n: integer;<br>begin<br> Result:=True;<br><br> tmpdb:=ExtractFilePath(destTableName);<br> tmpname:=ExtractFileName(destTableName);<br><br> DelTable(tmpdb,tmpName);<br><br> tmpTable.Close;<br> tmpTable.DatabaseName:=tmpdb;<br> tmpTable.TableName:=tmpname;<br> tmpTable.TableType:=ttParadox;<br> tmpTable.FieldDefs.Clear;<br> For i:=0 to aQuery.FieldDefs.Count-1 do begin<br> case aQuery.FieldDefs.DataType of<br> ftBlob,ftOraBlob:<br> begin<br> tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftBlob,0,aQuery.FieldDefs.Required);<br> end;<br> ftDate,ftDateTime,ftTime:<br> begin<br> tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftDateTime,0,aQuery.FieldDefs.Required);<br> end;<br> else begin<br> tmpTable.fielddefs.add(aQuery.FieldDefs.Name,aQuery.FieldDefs.DataType<br> ,aQuery.FieldDefs.Size,aQuery.FieldDefs.Required);<br> end;<br> end;<br> end;//for i<br> tmpTable.IndexDefs.Clear;<br> Try<br> TmpTable.CreateTable;<br> except<br> Result:=False;<br> ErrorMessage('创建表'+destTableName+'时出错,备份失败!');<br> SaveLog(tkeyword,toperation,ttitle,false);<br> Exit;<br> end;<br><br> tmpTable.Open;<br><br> tcount:=GetRecordCount(aQuery);<br> f_wait.ProgressBar1.Max:=tcount;<br> rno:=0;<br> j := 0;<br> n := 0;<br> aQuery.First;<br> aQuery.DisableControls;<br> While Not aQuery.Eof do begin<br> f_wait.ProgressBar1.Position:=rno;<br> Inc(rno);<br> inc;<br> f_wait.Refresh;<br> // While PeekMessage(msg,0,0,0,PM_REMOVE) do DispatchMessage(msg);<br> application.ProcessMessages;<br><br> F_WAIT.Label2.Caption := IntToStr(rno);<br><br> // IF rno = 457856 then<br> // showmessage('11111111111111111111111');<br><br> if n = 200001 then<br> begin<br> tmpTable.Close;<br> if CreateTable(aQuery,destTableName+'_'+IntToStr(j)) then<br> begin<br> n := 0;<br> inc(j);<br> tmpTable.Open;<br> end else<br> begin<br> Result := False;<br> tmptable.close;<br> ErrorMessage('创建表'+destTableName+'时出错,备份失败!');<br> SaveLog(tkeyword,toperation,ttitle,false);<br> Exit;<br> end;<br> end;<br><br> tmpTable.Append;<br> For i:=0 to aQuery.FieldDefs.Count-1 do begin<br> tmpname:=aQuery.FieldDefs.Name;<br> case aQuery.FieldDefs.DataType of<br> ftBlob,ftOraBlob:<br> begin<br> if Not TBlobField(aQuery.FieldByName(tmpname)).IsNull then<br> TBlobField(tmpTable.FieldByName(tmpname)).Assign(aQuery.FieldByName(tmpname));<br> end;<br> ftDateTime,ftDate,ftTime:<br> begin<br> if Not aQuery.FieldByName(tmpname).IsNull then begin<br> Try<br> tmpTable.FieldByName(tmpname).AsdateTime:=aQuery.FieldByName(tmpname).AsDateTime;<br> Except<br> end;<br> end;<br> end;<br> else begin<br> tmpTable.FieldByName(tmpname).AsString:=aQuery.FieldByName(tmpname).AsString;<br> end;<br> end;<br> end;//for i<br> Try<br> tmpTable.Post;<br> Except<br> tmpTable.Close;<br> Result:=False;<br> ErrorMessage('向表'+desttableName+'中保存数据时出错,备份失败!'<br> //Memo1.Lines.Add('向表'+desttableName+'中保存数据时出错,备份失败!');<br> SaveLog(tkeyword,toperation,ttitle,false);<br> end;<br> aQuery.Next;<br> end;//while<br> aQuery.EnableControls;<br> tmpTable.Close;<br>end;<br><br>function Tf_main.CreateTable(aQuery: TQuery; destTableName: String): Boolean;<br>var<br> i,rno,tcount:Integer;<br> tmpdb,tmpname:string;<br> msg:TMsg;<br> tmpstr:String;<br>begin<br> Result:=True;<br><br> tmpdb:=ExtractFilePath(destTableName);<br> tmpname:=ExtractFileName(destTableName);<br><br> DelTable(tmpdb,tmpName);<br><br> tmpTable.Close;<br> tmpTable.DatabaseName:=tmpdb;<br> tmpTable.TableName:=tmpname;<br> tmpTable.TableType:=ttParadox;<br> tmpTable.FieldDefs.Clear;<br> For i:=0 to aQuery.FieldDefs.Count-1 do begin<br> case aQuery.FieldDefs.DataType of<br> ftBlob,ftOraBlob:<br> begin<br> tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftBlob,0,aQuery.FieldDefs.Required);<br> end;<br> ftDate,ftDateTime,ftTime:<br> begin<br> tmpTable.fielddefs.add(aQuery.FieldDefs.Name,ftDateTime,0,aQuery.FieldDefs.Required);<br> end;<br> else begin<br> tmpTable.fielddefs.add(aQuery.FieldDefs.Name,aQuery.FieldDefs.DataType<br> ,aQuery.FieldDefs.Size,aQuery.FieldDefs.Required);<br> end;<br> end;<br> end;//for i<br> tmpTable.IndexDefs.Clear;<br> Try<br> TmpTable.CreateTable;<br> except<br> Result:=False;<br> end;<br><br>end;