Virtual Schema

<< Click to Display Table of Contents >>

Navigation:  Sources >

Virtual Schema

Virtual schema allows to combine different data sources. For example we can join JSON table and object list.

 

var
   VS: TDMVirtualSchema;
   CL: TCustList;
begin
  VS := TDMVirtualSchema.Create;
  try
    VS.RegisterDatasource('orders', THtJSONDatasource.CreatefromFile('c:\orders.json'));
    VS.RegisterDatasource('cust', THtRttiDatasource.CreatefromList(CL));
    THtSQL.FromSchema(VS, 'select c.name, o.order_date from orders o join customers c on c.cust_id = o.cust_id', []).ToDataset(FDMemTable1);
  finally
    VS.Free;
  end;
 

Note that schema should not be destoyed until query is released.