On 01/04/2011 04:56 p.m., Nate Lowrie wrote: > I have a bizobj for an addresses table. The addresses are tied to > customers, orders, and some other places in the system. The business > requirement is that we persist old address data for customers so that > the addresses tied to orders don't change. When a user edits an > address, if there are any changes, I need to be able to make a copy of > the data as a new record with the is_active field set to true and then > revert the old record and set it's is_active field to false. I would > like to define this at the bizobj level and I think it should go after > validation but before the save completes. > > Does this sound reasonable and if so, would any of y'all have a code > snippet for something like this?
Have done it in two different ways in the past. Usually I save the actual address with the order and that's it. But in some occasions I have created a trigger in the database that keeps a history of the table. That is, when you save a change (creating a new record is considered a change) the trigger will keep a copy of the actual state of the record, I keep the address's pk, the field name, date and time, and the new value of the changed field (yes, I keep history of changed fields as opposed to changed records, saves some space). Then with a simple query you can get the last value of every field of a record to a given date, which will allow to reconstruct your order's address. Have not had performance issues so far, but YMMV. _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
