2,498
社区成员
发帖
与我相关
我的任务
分享
//方式一:
for i:=0 to 10000 do begin
with insertQry do begin
close;
sql.Clear;
sql.Add('insert into myTbl(mID) values(:mID)');
parameters.ParamByName('mID').Value:=i;
ExecSQL;
end;
end;
//方式二:
insertQry.ClearFields;
for i:=0 to 10000 do begin
insertQry.Append;
insertQry.FieldByName('mID').Value:=i;
end;
insertQry.Post;
//两者的处理速度是否基本相同,如果相同,post是否逐一进行数据新增还是类似于select into呢?
for i:=0 to 100 do begin
with insertQry do begin
close;
sql.Clear;
for j:=0 to 99 do
begin
sql.Add('insert into myTbl(mID) values('+Inttostr(i*100+j)+')');
end;
ExecSQL;
end;
end;
tempQry.CursorType:=ctStatic;
tempQry.LockType:= ltBatchOptimistic;
)with tempQry do begin
close;
sql.Clear;
sql.Add('insert into myTbl(mID) values(:mID)');
prepared;
for i:=0 to 10000 do begin
close;
parameters.ParamByName('mID').Value:=i;
ExecSQL;
end;
end;
//方式二:
insertQry.ClearFields;
for i:=0 to 10000 do begin
tempQry.Append;
tempQry.FieldByName('mID').Value:=i;
end;
insertQry.Post;