Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Single result set from Multiple Remote Databases
Wed, Jun 26 2013 10:20 PMPermanent Link

Kreg Jetsel

I have 4 remote DBIsam databases - all with the same table names, structures, etc.  The tables contain basic customer information.  I would like to populate a grid with the customer lists from all 4 databases.  What would be the best way to accomplish this?  Is it possible to write one query against all 4 Databases at the same time?  Any help would be greatly appreciated.
Thu, Jun 27 2013 6:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Kreg

>I have 4 remote DBIsam databases - all with the same table names, structures, etc. The tables contain basic customer information. I would like to populate a grid with the customer lists from all 4 databases. What would be the best way to accomplish this? Is it possible to write one query against all 4 Databases at the same time? Any help would be greatly appreciated.

A couple of questions need answering first:

Is this c/s or f/s? (If the former then you'll need to stream the data back to the machine doing the consolidation, if fileserver then it may be possible to use a script.)

How much data is involved?

Is a query being used to extract data or is it everything in the table wanted?


As an example this is a post from 2003 by Robert to run a remote query and move the result to a local table.

procedure TDM.RemoteToLocal(RDS, LDS: tDBISAMDataSet; OpenLocal: Boolean;
CreateLocal : Boolean = True);
var M : tMemoryStream;
begin
   If not RDS.Active then RDS.Open;
   If LDS is tDBISAMTable then begin
       LDS.Close;
       If CreateLocal then begin
         (LDS as tDBISAMTable).DeleteTable;
         (LDS as tDBISAMTable).CreateTable;
       end;
       (LDS as tDBISAMTable).IndexFieldNames := '';
       (LDS as tDBISAMTable).DeleteAllIndexes;
       (LDS as tDBISAMTable).IndexDefs.Clear;
   end;
   If not LDS.Active then LDS.Open;
   try
     M := tMemoryStream.Create;
     RDS.SaveToStream(M);
     LDS.LoadFromStream(M);
   Finally M.Free; end;
   RDS.Close;
   LDS.Close;
   If OpenLocal then LDS.Open;
end;


One you have all the tables local then you can use a simple query using UNION

Roy Lambert [Team Elevate]

Image