TZUpdateSQL is used to update/add/delete records, as the source query is complicated (you use JOINs) or you want to conditionally change the data.
Then when you validate the edit in the database components (dbgrid, dbtext, etc.), queries from this component are automatically executed.
Of course, you can also call the data edit in code:
procedure TForm1.Button1Click(Sender: TObject);
begin
//for update query = 'update proccess set training=:training where sonumber=:sonumber and unitno=:unitno and proccessno=:proccessno and subprocno=:subprocno'
Dm.ZUPProcess.Edit;
Dm.ZUPProcess.FieldByName('training').AsInteger := 20; //new training value
Dm.ZUPProcess.Post;
end;
Only you have to remember that the parameter names must be the same as the column names in the source query, you can possibly use the prefixes
OLD_ and
NEW_ to separate the previous and new field values.
But if you want to manually modify the data, and you want to do it with a different query each time, then in my opinion there is no point in using
TZUpdateSQL just use
TZQuery and then your code will look more or less like this:
Dm.ZQuery.SQL.Text:='update proccess set training=:training where sonumber=:SoNumber and unitno=:unitno and proccessno=:proccessno and subprocno=:subprocno ';
Dm.ZQuery.Params.ParamByName('SoNumber').AsString := Dm.SQLSoOrders.FieldByName('SoNumber').AsString;
Dm.ZQuery.Params.ParamByName('unitno').AsInteger := Dm.SQLUnitsOrd.FieldByName('unitno').AsInteger;
Dm.ZQuery.Params.ParamByName('proccessno').AsInteger := Dm.SQLProccess.FieldByName('proccessno').AsInteger;
Dm.ZQuery.Params.ParamByName('subprocno').AsInteger := Dm.SQLProccess.FieldByName('subprocno').AsInteger;
Dm.ZQuery.Params.ParamByName('training').AsInteger :=Pass.DataSource.DataSet.FieldByName('training').AsInteger ;
Dm.ZQuery.ExecSQL;