Is it possible select records from TDAMemDataTable result to fill another TDAMemDataTable? Because Stored Procedure will return multiple dataset. But TDAMemDataTable can’t handle multiple datasets. So I want to fill all data into TDAMemDataTable and then split into different TDAmemDataTable by different purpose.
How do you want to filter them? by some field value?
you can use the ClonedSource feature and have one main table and a lot of cloned tables. each cloned table can have own sorting, filter and can be used in m/d relation
see more about this feature at the ClonedSource article
I want to doing some summarize queries from DAMemDataTable. Something like Devart’s TVirtualQuery component. TVirtualQuery can using SQLite to doing some SQL statement from dataset. For example select different summary dataset from detail transactions in DAMemDataTable.
I’m no familiar with Devart’s components.
if all your tables have the same struct, you can hold all of them in one TDAMemDataTable. you can distinguish them by some field.
1st table can have, say, 1 in
Index field, 2nd tabel - 2, etc
later you can filter by this field
The issue is not filter. The different datasets are data grouping by detail records. For example 1 dataset is Sales order by monthly, 1 dataset is Sales order by quarterly, 1 dataset is daily sales. All of them is showing in the pagecontrol. If need to connect the DB server 4 times, then it will slower than connect 1 time and using SQL to split to 4 different result sets.
Why you can’t open stored procedure on server side, split result to several datasets on server-side and return them in one stream to client-side?
later you can read 4 tables from this stream on client-side
Because the stored procedure is belong to application vendor. I can’t do anything in server side. If I change it, the system will down. I only can reuse their stored procedure and then doing the other analysis.
DataAbstract driver is a wrapper to native DAC (direct access component) so you can open stored procedure with DAC’s components and later you can write received tdataset to stream
Is it possible clone DAMemDataTable to standard ClientDataSet?
You can use DaMemDataTable.Dataset - this is descendant of TDataset.
ClientDataSet may allow to clone TDataset to itself…
why do you need to clone DAMemDataTable to ClientDataSet?
SDAC’s VirtualQuery can support Delphi standard Data Table such as ClientDataSet, FDMemTable. If it can clone DAMemDataTable to those DataSet, then my existing application can migrate to DA. Otherwise, I need to find the other solution to solve multiple dataset return from stored procedure.
you can get SDAC’s
TMSQuery or SDAC’s
TMSStoredProc after opening stored procedure.
VirtualQuery should support those components.
later you can migrate data from TDataset’s descendant to TDAMemDataTable via TDADatasetWrapper.
SDAC is 2-tiers design that connects to DB directly. Now I’m revamp the application to RemObjects. I only can apply VirtualQuery in client side that is using for second querying from TDAMemDataTable. But VirtualQuery don’t support TDAMemDataTable. I need to migrate TDAMemDataTable to TDataset and then using VirtualQuery to create different datasets.
you don’t need to migrate TDAMemDataTable to TDataset.
just use the table.Dataset property.
I tried the following statement that has the error. (Clientdataset1 is TClientDataSet)
Clientdataset1.DataSource.DataSet := ClientDataModule.tbl_Users.Dataset;
TDAMemoryDataset = class(TDataset)
so you can’t use it as TClientDataSet.
you may try to use legacy
TDACDSDataTable. it uses TClientDataSet internally. of course, not all features of TDAMemDataTable are implemented here.
note: that unit wasn’t updated since XE7 so you may need to update to the latest version of Delphi. check
THackCustomClientDataSet declaration inside unit.
I tried it also failed. But I found the old post in here that mention the following code can clone to other dataset. I tried and failed also.
aDataSet := TDatasetWrapper.Create(Clientdatamodule.tbl_Users.Dataset);
aDataSet.LogicalName := ‘Dataset1’;
aStream := TROBinaryMemoryStream.Create();
DABin2DataStreamer1.WriteDataset(aStream, aDataSet, [woRows, woSchema]);
ClientDataSet1.DataSource.RemoteFetchEnabled := False;
DABin2DataStreamer1.ReadDataset(aStream, ClientDataSet1, True, ‘Dataset1’
you can use also this code:
memtable.SaveToStream(stream); cdstable.RemoteDataStreamer := memtable.RemoteDataStreamer; cdstable.LoadFromStream(stream);
cdstable look like not TClientDataSet. I tried to using following code that return the error “Mismatch in datapacket”
tmpdataset := TMemoryStream.Create;
cdstable.dataset is TClientDataSet
Note: you can use TDACDSDataTable instead of TDAMemDataTable on client-side