EmptyDataSet causes Post Error, Why?

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

EmptyDataSet causes Post Error, Why?

Post by louis »

Hallo,
I used EmptyDataSet because I supposed that is the right method for doing my chance but it seems not works correctly.
I wish delete all records presents on DetailDataset then repopulate it with a new data with a possibility of cancel those updates. New data can contain old keys or not.
This is my code:

Code: Select all

    
    DetailDataset.EmptyDataset;
    for Indice := 0 to (Lista.Count - 1) do
    begin
        DetailDataset.AppendRecord([ID, Lista.Strings[Indice]);
    end;
DetailDataset is linked to a master dataset via "Datasource"
CachedUpdates setting is:
For DetailDataset = True
For MasterDataset = False

When I post MasterDataset I receive the error: Violation of PRIMARY or UNIQUE KEY constraint "DetailDataset_PK" on table "DetailDataset" Problematic key values is "Master_ID = 83", Detail_ID = "22" ... no 2 table rows can have duplicate column values.

if I substitute DetailDataset.EmptyDataset with this code, all works I desired:

Code: Select all

 
 while not DetailDataSet.Eof do
    DetailDataSet.Delete;
What I wrong?

Thanks
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: EmptyDataSet causes Post Error, Why?

Post by marsupilami »

Hello louis,

which version of Zeos and which database do you use? I could assume it is Firebird form the error messages but I am not sure? Are you in Autocommit mode? Did you start an explicit transaction if you are in autocommit mode?
With best regards,

Jan
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: EmptyDataSet causes Post Error, Why?

Post by louis »

marsupilami wrote:which version of Zeos and which database do you use?
ZEOS 7.1.4 for Firebird 2.5.4
Are you in Autocommit mode?
Yes
Did you start an explicit transaction if you are in autocommit mode?
Not.

Thanks
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: EmptyDataSet causes Post Error, Why?

Post by marsupilami »

Hello louis,

I did a quick check in the code. It seems that EmptyDataset only clears the internal row buffer of the dataset but doesn't do anything on the database. I am not sure why that procedure even exists but it clearly is not what you want. I also am unsure what it was meant for.
With best regards,

Jan
Post Reply