Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Implementing UNDO/REDO Functionality in a Relational Database
Mon, Dec 10 2007 2:40 PMPermanent Link

"Johnnie Norsworthy"
In DBISAM 4...

I would like to have some form of reversion to a previous record contents
after a user has edited a record, and the ability to return to the changed
version if the old version wasn't what they wanted. Since the master record
may have a number of detail records I am uncertain how to implement this
sort of "undo/redo" system.

Is there any database or programming design pattern to handle this sort of
thing or do I simply need to roll my own design for this will duplicate
tables for all the undo/redo functionality. Maybe something that would not
require duplicate tables but could be implemented using additional fields
and time stamps or somthing.

I am not talking about simple rollback on a transaction. I would like to
have the ability to restart my program and revert to a previously stored
record value if an "undo record" or "redo record" or "restore deleted" is
present. I blame Allan Cooper for this need for undo and no confirmation
prompts. <grin>

Any ideas appreciated.

-Johnnie

Tue, Dec 11 2007 7:00 AMPermanent Link

In the past I've included a "Revision" value and each time you edit you
increment that value and save to a new record. Searches then use the
largest value of the revision, perhaps with a TOP value. You can also tidy
it my removing older items.

/Matthew Jones/
Thu, Dec 13 2007 7:38 AMPermanent Link

"Johnnie Norsworthy"
"Matthew Jones" <matthew@matthewdelme-jones.delme.com> wrote in message
news:memo.20071211115500.5156F@nothanks.nothanks.co.uk...
> In the past I've included a "Revision" value and each time you edit you
> increment that value and save to a new record. Searches then use the
> largest value of the revision, perhaps with a TOP value. You can also tidy
> it my removing older items.

Matthew,

Thanks for your suggestion. I hadn't posted sooner because I was hoping for
some more ideas and to respond to all at once.

I guess that implies that few people have implemented such a roll-back
feature. What I am leaning toward is when the file is opened I duplicate the
active master record and flag it with the last edit date in a field called
"UndoDate", and I do the same with any detail records. So they can always go
back one edit session.

In the undo/redo to previous date function I could basically load the older
date and when they save it will be a newer date and the process can still
undo back to the previous recent date.

-Johnnie

Thu, Dec 13 2007 9:40 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Johnnie


Years ago (c1985) I did implement something like that. What I did was log every alteration to the database - table, record, field, old value, new value, date, time and built the systems to restore anything to any point. Three years later when the company was acquired and we shut that system down it hadn't been used.

I presume this is an existing system that you want to retrofit the functionality onto. If not you have a few more options.

One idea has just occurred to me - its a bit (probably a lot) more programming - in a before post event or equivalent, work out the necessary sql to reverse the changes (eg if they've just inserted a record delete it) and store a script.

Roy Lambert
Thu, Dec 13 2007 9:55 AMPermanent Link

"Johnnie Norsworthy"
"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:8D4B8F81-78AA-42D4-8BFB-5B945658B03E@news.elevatesoft.com...
> Years ago (c1985) I did implement something like that. What I did was log
> every alteration to the database - table, record, field, old value, new
> value, date, time and built the systems to restore anything to any point.
> Three years later when the company was acquired and we shut that system
> down it hadn't been used.

It may never be used, but I look at this as a paid learning experience for
future products and something I can just design into new systems.

> One idea has just occurred to me - its a bit (probably a lot) more
> programming - in a before post event or equivalent, work out the necessary
> sql to reverse the changes (eg if they've just inserted a record delete
> it) and store a script.

I can't really do this because I am going to have multiple pages of data
entry for a single record and I want automatic saving when clicking among
the tabs or transferring focus to another form. Basically, I want to
eliminate any "save" operation and have it just work like a person would
think about writing something down with a pen - when you type it in, it is
saved. Of course that means that all changes for one edit session would be
recorded with the same timestamp which will involve keeping track of that,
but no big deal.

-Johnnie

Thu, Dec 13 2007 10:25 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Johnnie



>I can't really do this because I am going to have multiple pages of data
>entry for a single record and I want automatic saving when clicking among
>the tabs or transferring focus to another form. Basically, I want to
>eliminate any "save" operation and have it just work like a person would
>think about writing something down with a pen - when you type it in, it is
>saved.

I hate that. Years ago I worked at a consultancy that used Samna word processor that saved as you went. No ability to cancel changes or give up is despair.

Roy Lambert
Thu, Dec 13 2007 4:57 PMPermanent Link

"Johnnie Norsworthy"
"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:CBB000BB-FBB0-4DBE-ADD7-010ECC3A3A22@news.elevatesoft.com...
> I hate that. Years ago I worked at a consultancy that used Samna word
> processor that saved as you went. No ability to cancel changes or give up
> is despair.

But what a pain in a field edited form to always save, but still allow undo
of each field. What's the compromise? Maybe just using [Esc] key or a
[Cancel] button to abandon changes on the visible tab? What's the best wat
to handle the UI? I would prefer the [Esc] key, personally.

I truly do not like [Save] buttons and "Do you want to save?" dialogs.

-Johnnie

Fri, Dec 14 2007 3:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Johnnie


I tend to use "implicit" post a lot. I have a full set of buttons (insert/post & delete/cancel share buttons, first/last/next/previous have their own) but rely in many cases on the fact that moving to a different record posts any changes on the current one. This is backed up with a check when closing the system down to make sure that any pending changes are either posted or cancelled.

Roy Lambert
Image