Recent

Author Topic: zeosdb zupdate don't works  (Read 306 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 543
zeosdb zupdate don't works
« on: March 15, 2025, 05:09:22 am »
HI i don't know what i doing wrong zupdate not make changes on table
any error but don't affect table information
Code: Pascal  [Select][+][-]
  1.  
  2.     Dm.ZUPProcess.ModifySQL.Text:='update proccess set training=:training where sonumber=:SoNumber and unitno=:unitno  and proccessno=:proccessno and subprocno=:subprocno ';
  3.     Dm.ZUPProcess.Params.ParamByName('SoNumber').AsString:= Dm.SQLSoOrders.FieldByName('SoNumber').AsString;
  4.     Dm.ZUPProcess.Params.ParamByName('unitno').AsInteger:= Dm.SQLUnitsOrd.FieldByName('unitno').AsInteger;
  5.     Dm.ZUPProcess.Params.ParamByName('proccessno').AsInteger:= Dm.SQLProccess.FieldByName('proccessno').AsInteger;
  6.     Dm.ZUPProcess.Params.ParamByName('subprocno').AsInteger:= Dm.SQLProccess.FieldByName('subprocno').AsInteger;
  7.     Dm.ZUPProcess.Params.ParamByName('training').AsInteger:=Pass.DataSource.DataSet.FieldByName('training').AsInteger ;
  8.     Dm.SQLProccess.Edit;
  9.     Dm.SQLProccess.UpdateRecord;
  10.     Dm.ZUPProcess.ModifySQL.Text:= '';
  11.  
  12.  
  13.  
on image my sql and zupdate settings..


paweld

  • Hero Member
  • *****
  • Posts: 1361
Re: zeosdb zupdate don't works
« Reply #1 on: March 15, 2025, 06:59:14 am »
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:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   //for update query = 'update proccess set training=:training where sonumber=:sonumber and unitno=:unitno  and proccessno=:proccessno and subprocno=:subprocno'
  4.   Dm.ZUPProcess.Edit;
  5.   Dm.ZUPProcess.FieldByName('training').AsInteger := 20;   //new training value
  6.   Dm.ZUPProcess.Post;
  7. 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:
Code: Pascal  [Select][+][-]
  1.   Dm.ZQuery.SQL.Text:='update proccess set training=:training where sonumber=:SoNumber and unitno=:unitno  and proccessno=:proccessno and subprocno=:subprocno ';
  2.   Dm.ZQuery.Params.ParamByName('SoNumber').AsString := Dm.SQLSoOrders.FieldByName('SoNumber').AsString;
  3.   Dm.ZQuery.Params.ParamByName('unitno').AsInteger := Dm.SQLUnitsOrd.FieldByName('unitno').AsInteger;
  4.   Dm.ZQuery.Params.ParamByName('proccessno').AsInteger := Dm.SQLProccess.FieldByName('proccessno').AsInteger;
  5.   Dm.ZQuery.Params.ParamByName('subprocno').AsInteger := Dm.SQLProccess.FieldByName('subprocno').AsInteger;
  6.   Dm.ZQuery.Params.ParamByName('training').AsInteger :=Pass.DataSource.DataSet.FieldByName('training').AsInteger ;
  7.   Dm.ZQuery.ExecSQL;
Best regards / Pozdrawiam
paweld

eldonfsr

  • Hero Member
  • *****
  • Posts: 543
Re: zeosdb zupdate don't works
« Reply #2 on: March 15, 2025, 06:11:23 pm »
Thanks paweld have is tzquery but ithougth use tzupdate can more simple could be in some task is more simple for other is not the right way to do  that....

i goin to use tzupdat for update or delete  datas for table or tzquery...

Thanks so much for you r advance...

 

TinyPortal © 2005-2018