Page 1 of 1

Fast way to insert 100k records to Firebird

Posted: Thu 06 Nov 2008 11:38
by flashfast
i'm using Unidac to connect to FireBird.

i want to import other data from text to Firebird database, about 100k records.

If use normal way it same too slow
i current using

for I := 0 to recordcount do
begin
UniQuery1.SQL.Text:= (sqlstr);
UniQuery1.Execute;
end;

Is there other way to do it faster .?

Thank

Posted: Fri 07 Nov 2008 11:28
by Plash
Try to use a SQL statement with parameters:

Code: Select all

UniQuery1.SQL.Text := 'INSERT INTO Table1(a, b) VALUES (:a, :b)';
UniQuery1.ParamByName('a').DataType := ftInteger; 
UniQuery1.ParamByName('b').DataType := ftString;
UniQuery1.Prepare;
for I := 0 to recordcount do 
begin
  UniQuery1.ParamByName('a').Value := I; 
  UniQuery1.ParamByName('b').Value := I;
  UniQuery1.Execute;
end;
UniQuery1.Unprepare;