I'm expanding previous discussion.
https://forum.lazarus.freepascal.org/index.php/topic,60674.0.htmlI'm testing TSQLQuery.ApplyUpdates, but the content of TSQLQuery is copied from TBufDataSet (or any other dataset).
To explain, with direct opening of a TSQLQuery like:
qr1.SQL.Text := 'select * from testtable'; // There is a primary key.
qr1.Open; I can do editing (insert, delete, and modify records). In this case, to save the changes, I only have to call
qr1.ApplyUpdates; without specifying UpdateSQL, DeleteSQL and InsertSQL (qr1.UsePrimaryKeyAsKey = true).
Now I'd like to download a set of records from webserver, and edit it on client PC, and then save it back.
So I made a simple test application having both TSQLQuery(qr1) and TBufDataSet (bds1). First I open qr1, copy it to bds1, edit with bds1, and then copy bds1 back to qr1. And I'd like to check whether I can call qr1.ApplyUpdates.
qr1.SQL.text := 'select * from testtable';
qr1.Open;
qr1.SaveToStream(AMemoryStream);
// As you know, AMemoryStream must sail over Internet in real world
bds1.LoadFromStream(AMemoryStream);
qr1.Close;
// database editings are done here --- datasource is linked to bds1.
// After editing,
bds1.SaveToStream(AMemoryStream);
// Again, AMemoryStream must sail over Internet in reality
qr1.LoadFromStream(AMemoryStream);
qr1.ApplyUpdates;
But at the last ApplyUpdates, there occur exceptions --- it says UpdateSQL or DeleteSQL's fields are not defined, etc. Should I compose all the SQLs or is there any simpler way?