Exesql directly executes SQL statements, but it has nothing to do with cachedupdates.
Cachedupdates is used to cache the modified data in tTable or tquery until it is called.
Applyupdates.
Applyupdates submits the data that has been modified but submitted in tquery or tTable,
And only cachedupdates of the tquery or tTable object is set to true and active to true,
State = dsbrowse.
The cachedupdates of tquery must be used with the tupdatesql control.
For example:
Query1. SQL. Text: = 'select field1, field2 from table1 ';
Query1.cachedupdates: = true;
Query1.updateobject: = updatesql1;
Updatesql1.insertsql: = 'insert Table1 (field1, field2) values (: field1,: field2 )';
Updatesql1.deletesql: = 'delete from Table1 where field1 =: field1, field2 =: field2 ';
Updatesql1.modifysql: = 'Update Table1 set field1 =: field1, field2 =: field2 where field1 =: old_field1 and field2 =: old_field2;
Query1.open;
Query1.first;
While not query1.eof do begin
Query1.edit;
Query1.fieldbyname ('field1'). asstring: = '20140901 ';
Query1.post; // data is not submitted to the background at this time.
Query1.next;
End;
Query1.database. starttransaction
Try
Query1.applyupdates;
Query1.database. commit;
Except
Query1.database. rollbback;
Raise;
End;
Query1.commitupdates;