DELETE FROM in Delphi EX2 with SQLite3 silently failing

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
BytePlayer
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 21.09.2012, 10:13

DELETE FROM in Delphi EX2 with SQLite3 silently failing

Post 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?
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post 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....
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
BytePlayer
Fresh Boarder
Fresh Boarder
Posts: 24
Joined: 21.09.2012, 10:13

Post 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.
Locked