Hi guys. This is my scenario:
Hi guys. This is my scenario:
Standalone Datasnap Server with a couple GetXXX: TFDJSONDataSets;
The server pulls the data from a MS SQL Server through FireDAC.
These functions all follow the same structure:
function GetXXX: TFDJSONDataSets;
begin
AFDQuery.Active := False;
Result := TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, AFDQuery);
end;
So far so good. Now I consume the server from Mobile (mainly Android). I can get the data, display it on some control, do whatever-i-want.
To get the data on the client side, i use something like this
var
JsonData: TFDJSONDataSets;
begin
// MemTab here is a TFDMemTable
JsonData := Methods.GetXXX;
MemTab.AppendData(TFDJSONDataSetsReader.GetListValue(JsonData, 0));
MemTab.Open;
end;
What I need to do is to save this data locally. I'm using SQLite and I'm doing it in an old-fashioned while not Eof loop. Is there a better approach? Like, dumping the whole data into a SQLite table?
I'm ok with "deleting all the old stuff and put the fresh one". The only purpose of the local data is to cache and offline-stuff. Then, there will be a "synchronize all" button. Yep, not very cool but that's what's required :)
Standalone Datasnap Server with a couple GetXXX: TFDJSONDataSets;
The server pulls the data from a MS SQL Server through FireDAC.
These functions all follow the same structure:
function GetXXX: TFDJSONDataSets;
begin
AFDQuery.Active := False;
Result := TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, AFDQuery);
end;
So far so good. Now I consume the server from Mobile (mainly Android). I can get the data, display it on some control, do whatever-i-want.
To get the data on the client side, i use something like this
var
JsonData: TFDJSONDataSets;
begin
// MemTab here is a TFDMemTable
JsonData := Methods.GetXXX;
MemTab.AppendData(TFDJSONDataSetsReader.GetListValue(JsonData, 0));
MemTab.Open;
end;
What I need to do is to save this data locally. I'm using SQLite and I'm doing it in an old-fashioned while not Eof loop. Is there a better approach? Like, dumping the whole data into a SQLite table?
I'm ok with "deleting all the old stuff and put the fresh one". The only purpose of the local data is to cache and offline-stuff. Then, there will be a "synchronize all" button. Yep, not very cool but that's what's required :)
Comments
Post a Comment