Page 1 of 1

DELETE FROM in Delphi EX2 with SQLite3 silently failing

Posted: 29.09.2012, 20:26
by BytePlayer
I have a SQLite3 Database and have set the tzConnection to auto-commit but when I run the following procedure it does nothing to the table, the record count remains unchanged.

procedure EmptyTable(inTable:tzTable);
begin
MyQuery:=tzQuery.Create(nil)
MyQuery.Connection := inTable.Connection;
MyQuery.SQL.Text := 'DELETE FROM '+inTable.TableName ;
MyQuery.ExecSQL;
MyQuery.free;

if inTable.RecordCount > 0 then
Raise Exception.Create('DELETE FROM '+inTable.TableName+' Failed';
end;

Everything APPEARS to work without an error but then RecordCount remains unchanged and it always throws the exception.

What could I possibly be doing wrong?

Posted: 29.09.2012, 21:08
by EgonHugeist
BytePlayer,

how can InTable know that a second query was dropping the rows? Refresh/reopen inTable first and then everything is fine. The TZDataSet Components are cached(the SQLite protocol is forward_only and fetches all rows before closing the stmt handle) so if MyQuery deletes the data of inTable.TableName then InTables can't know this....

Posted: 29.09.2012, 21:56
by BytePlayer
Okay, I'll give that a shot!

Thanks for the quick feedback.

Also, slightly off topic, but where is the best documentation for the Zeoslib components? There are quite a number of components, like Sequencers, that I haven't run into before but I can't find a good explanation of what they are used for.