Recent

Author Topic: ZMSQL Update question  (Read 1266 times)

scons

  • Full Member
  • ***
  • Posts: 141
ZMSQL Update question
« on: January 30, 2018, 12:48:47 pm »
Hi all,

I have found some time to test some more with ZMSQL.

I ran in to the following: you have 2 tables (table1, table2), I want to update table1 with data from table2 where 2 values (or ID's) match.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.BtnUpdateClick(Sender: TObject);
  2. begin
  3.   ZMQueryDataSet3.SQL.Clear;
  4.   ZMQueryDataSet3.SQL.AddText('UPDATE table1 SET zghl1 = (SELECT table2.SL FROM table2 WHERE table2.ID=table1.PNR; COMMIT;)');
  5.   ZMQueryDataset3.QueryExecute;
  6. end;
  7.  

Table1 gets altered but no update (values stay the same), so I think there must be something wrong with the SELECT part ?

I also tried :
Code: Pascal  [Select][+][-]
  1.   ZMQueryDataSet3.SQL.AddText('UPDATE table1 SET zghl1 = (SELECT table2.SL as zghl1 FROM table2 WHERE table2.id=table1.pnr; COMMIT;)');
  2.  

but no updates, what am I missing here ?

Thanks
« Last Edit: February 04, 2018, 02:32:15 pm by scons »
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

scons

  • Full Member
  • ***
  • Posts: 141
Re: ZMSQL Update question
« Reply #1 on: February 04, 2018, 02:35:39 pm »
I think I am missing something in the "SELECT" procedure.

Would someone be so kind to explain why my SELECT button does show an empty result ?

Thanks
Windows 10-64bit Lazarus 2.0.12 + FPC 3.2.0

 

TinyPortal © 2005-2018