There are different ways depends of what you want and what you use.
If you wish to edit several rows into DBGrid and save them simultaneously, most dataset components supports a CachedUpdate
mode (look into the Zeos documentation for details). In this mode dataset holds all changes made until you call ApplyUpdates
method to put these changes into DB using one batch.
Using Oracle, you can do it without cached updates, just use 'long transaction'. In this case you should start transaction when form opens, edit and post data at usual way and commit them when Save
pressed. This way have some disadvantages, but I doubt you'll face them.
If you wish to do some sort of mass update when pressing Save
button, you have two ways. First of all, you can set up a query component, set it's SQL property into something like
update My_Table set My_Field_1 = :Value1, My_Field_2 = :Value2
and call it into save action handler:
qUpdate.Params.ParamByName('Value1').AsString := edFirstValue.Text;
qUpdate.Params.ParamByName('Value2').AsString := edSecondValue.Text;
qUpdate.ExecSQL;
qMain.Refresh; { we're in need to see updates values, yeah? }
Otherwise, you can do it from client:
qMain.DisableControls;
try
Bookmark := qMain.Bookmark;
qMain.First;
while not qMain.Eof do
begin
qMain.Edit;
qMain.FieldByName('My_Field_1').AsString := edFirstValue.Text;
qMain.FieldByName('My_Field_2').AsString := edSecondValue.Text;
qMain.Post;
qMain.Next;
end;
finally
qMain.Bookmark := Bookmark;
qMain.EnableControls;
end;
That's, generally, not so good way, so don't addict of that.