Hi
Here is the code I have currently. It is just a test program where I attempt to get the most basic transaction working:
Query1.CachedUpdates := True;
Database1.StartTransaction;
{ the test table has a code (pk), client_id, description, amount fields }
try
{ take 100 rand from bob }
tmp := 'insert into trans.db values (501, 100, "give2yoda", -100)';
Query1.SQL.Clear;
Query1.SQL.Add(tmp);
Query1.ExecSQL;
{ sometimes I kill the application at this point - for testing }
MessageDlg('Ok, kill me now if you want...', mtInformation, [mbOk], 0);
{ .... }
{ now give to yoda }
tmp := 'insert into trans.db values (502, 500, "frombob", 100)';
Query1.SQL.Clear;
Query1.SQL.Add(tmp);
Query1.ExecSQL;
if Query1.UpdatesPending then
begin { this block never gets executed, why????? }
MessageDlg('Updates pending', mtInformation, [mbOk], 0);
Query1.ApplyUpdates;
Database1.Commit;
Query1.CommitUpdates;
end
else
MessageDlg('NO updated pending', mtInformation, [mbOk], 0);
except
Database1.Rollback;
end;
As I understand, the "Query1.CachedUpdates" is suppose to keep the inserts
in a buffer, until " Query1.ApplyUpdates" actually writes it and
"Database1.Commit" commits the changes. For some unkown reason, however, I
keep on getting the message "No updates pending...". Furthermore, if I kill
the application at the point indicated in the program, the one transaction
is actually present in the table, and according to me, it shouldn't be
there. Isn't it suppose to be all or nothing??
Please help!!
Regards