Subject Re: [IBO] Copy entire records without specifying the fields? IB_Datapump?
Author John vd Waeter
Woody wrote:
> From: "John vd Waeter" <john@...>
>>I know you're quite busy getting the IBO-update finished, but could you
>>point me in a direction: how do I connect the datapump to 2 databases A
>>and B and how can I make it insert records from A.Table into B.table?
> It may not be what you want because it would be slower, but, here is a
> routine I use when I want to copy from one table to another. It doesn't
> matter where the tables reside. Just create the queries using the right
> select/insert statements and this will work:
> function CopyRecord(T1, T2: TIB_Query): boolean;
> var
> x: integer;
> begin
> try
> if not (T2.State in [dssEdit, dssInsert]) then
> T2.Edit;
> for x := 0 to T1.FieldCount - 1 do
> try
> if T2.FindField(T1.Fields[x].FieldName) <> nil then
> if T1.Fields[x].IsNull then
> T2.FieldByName(T1.Fields[x].FieldName).Clear
> else
> T2.FieldByName(T1.Fields[x].FieldName).Value :=
> T1.Fields[x].Value;
> except
> // eating any exceptions, dangerous but we don't care here...
> end;
> Result := True;
> except
> raise;
> end;
> end;
> You can use this as you loop through the source dataset and call it on each
> record. If you don't call insert on the destination dataset, this function
> assumes you want to edit the record. You can change that to whatever you
> want or leave it as is.

Hi Woody,

At the moment I kinda use this approach, using commits every 100
records. As Jason mentions, the buffered data now gets copied which
would not be necessary when using the datapump, so I hope he has some
minutes to show some example code...

Thanks for your example!

Kind regards,