Subject [firebird-support] Re: Simultaneous inserts / selects
Author Svein Erling Tysvær

>All values for inserts are converted to string so there are no parameters.

 

Sorry to hear that.

 

MyStatement.SQL.Text:=’INSERT INTO MyTable(Field1, Field2) VALUES (:Param1, :Param2)’;

MyStatement.Prepare;

while not eof(InputFile) do

begin

  readln(InputFile);

  MyStatement.Params[0].AsInteger:=<IntegerFromFile>;

  MyStatement.Params[1].AsString:=<StringFromFile>;

  MyStatement.Execute;

end

MyTransaction.Commit;

 

is magnitudes faster (5 000 records per second could be feasible) than

 

while not eof(InputFile) do

begin

  readln(InputFile, s);

  MyStatement.SQL.Text:=s;

  MyStatement.Prepare;

  MyStatement.Execute;

end

MyTransaction.Commit;

 

I only know of two ways to go if you want decent performance for largish inserts, one is to use external tables (I’ve never used them, but I trust they are the quickest way), the other statements that you prepare before the loop and use with parameters.

 

Sorry,

Set