数据导入问题 orcal(100分)

  • 主题发起人 主题发起人 playermeng
  • 开始时间 开始时间
P

playermeng

Unregistered / Unconfirmed
GUEST, unregistred user!
往orcal库导入数据时,一次导大概20000条 第一次导很快,导入语句为:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SQL.Add('insert into gzryxxb(rydm,xm) values(' + inttostr(i) + ',''' + mc + ''')');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ExecSQL;<br>问什么第二次就导不进去 也不报任何错误。跟踪时走到ExecSQL这就 不动了。
 
commit行吗。
 
估计表被锁了
 
没有锁,具体代码:<br>&nbsp;try<br>&nbsp; &nbsp; with tbl1 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Close;<br>&nbsp; &nbsp; &nbsp; Open;<br>&nbsp; &nbsp; &nbsp; pb1.Visible := True;<br>&nbsp; &nbsp; &nbsp; pb1.Max := RecordCount;<br>&nbsp; &nbsp; &nbsp; First;<br>&nbsp; &nbsp; &nbsp; i := StrToInt(edt1.Text);<br><br>&nbsp; &nbsp; &nbsp; while not Eof do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; pb1.Position := RecNo;<br>&nbsp; &nbsp; &nbsp; &nbsp; mc := tbl1.FieldByName('name').AsString;<br>&nbsp; &nbsp; &nbsp; &nbsp; orcalqry := TADOQuery.Create(nil);<br>&nbsp; &nbsp; &nbsp; &nbsp; orcalqry.Connection := con2;<br>&nbsp; &nbsp; &nbsp; &nbsp; with orcalqry do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Close;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SQL.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //SQL.Add('insert into test(name,id) values(''' + mc + ''',' + inttostr(i) + ')');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SQL.Add('insert into gzryxxb(rydm,xm) values(' + inttostr(i) + ',''' + mc + ''')');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ExecSQL;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Free;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; Next;<br>&nbsp; &nbsp; &nbsp; &nbsp; Inc(i);<br>&nbsp; &nbsp; &nbsp; end;<br>就是说第一次i=40000开始导是可以的,从库里把大于4000的删了,第二次导i=4000就不可以了,必须重启机器或者i&lt;&gt;40000就可以了。
 
是不是你的表中设了索引或是主键什么的,如果你这个表是用来导数据用的,那就什么都不设,那样还能加快插入数据速度,然后再用个什么procedure把数据至你需要的表中
 
后退
顶部