Board index » delphi » Transaction and TDBGrid: how to get back a deleted record after RollBack

Transaction and TDBGrid: how to get back a deleted record after RollBack

I have a TDBGrid displaying records from a TADODataSet. Every time user
wants to change data I start a transaction if no transaction is yet started.
After making all changes user has two options: commit or rollback.
Suppose user deleted a record. It disappeared from the TDBGrid. Then user
rolled back but the record is  gone. Only when I do lengthy Requery the
record is back.
Is there any way to restore the deleted records (or to remove inserted) upon
transaction rollback?

Alex

 

Re:Transaction and TDBGrid: how to get back a deleted record after RollBack


Quote
>Is there any way to restore the deleted records (or to remove inserted) upon
>transaction rollback?

other than the Requery I do not believe you can get the deleted records back.
Instead of a transaction I suggest you do this in BatchOptomisic mode (See
UpdateBatch method)

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Transaction and TDBGrid: how to get back a deleted record after RollBack


Thank you Brian, I think I will end up by Requerying, but what I was
thinking about was a way of telling and TADODataSet to recover a deleted
record from it's internal buffers, which as you say does not exist.

Do you think that such method is theoretically correct? I am convinced that
ADO just marks records as deleted and does not actually free their memory
buffers immediately upon deletion. Is that correct? If yes, it would make
sense to have a method like Restore to undelete such records and remove
inserted records.

I realize that recovering original values of the modified records is no that
simple and much more memory consuming - this is probably not an issue.

Alex

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:msks6tsfa1ddcmh6gq5ga3mklrnqo69lmu@4ax.com...

Quote

> >Is there any way to restore the deleted records (or to remove inserted)
upon
> >transaction rollback?
> other than the Requery I do not believe you can get the deleted records
back.
> Instead of a transaction I suggest you do this in BatchOptomisic mode (See
> UpdateBatch method)

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Transaction and TDBGrid: how to get back a deleted record after RollBack


Quote
>Do you think that such method is theoretically correct? I am convinced that
>ADO just marks records as deleted and does not actually free their memory
>buffers immediately upon deletion. Is that correct?

I don't know the answer to that question.

Quote
>If yes, it would make
>sense to have a method like Restore to undelete such records and remove
>inserted records.

As I said in my previous message for what you want to do you should be using
batchOpomistic mode

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Transaction and TDBGrid: how to get back a deleted record after RollBack


Oops, I should have said 'visually undelete' to avoid confusion. Actually,
after some digging in the VCL source I am convinced that it's possible to
partially restore the dataset to it's initial state after rolling back a
transaction. The datalink object sounds quite promising I have to
investigate more.

Alex

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:j9c47tg84hl3tm5ipq0kg7kdl85entjsvo@4ax.com...

Quote
> >If yes, it would make
> >sense to have a method like Restore to undelete such records and remove
> >inserted records.

> As I said in my previous message for what you want to do you should be
using
> batchOpomistic mode

Other Threads