HI,
II have several transaction tables which will keep "live" data for 6 months. After that time, I want to write the data (once a month) to an archive table and delete it from the live table. How are folks doing this. Do you clone the file in the dictionary and name the clone of the file to something like Filename_Archive.tps? Are there other strategies? I have about 6 tables that will get "cleaned out" every month to archive records > 6 months old.
Just wanting to see if folks have more elegant solutions to this.
Thanks,
Ron
Hi Ron,
Our ProArchive template gives you a pretty easy way to do this.
https://www.clarionproseries.com/products/proarchive
The really nice thing about it is that you don't need to write any special Browse, Form or Reports to access the archived data. You simply "switch" to the other file and everything works like it usually does.
You can also move records back and forth between the active file and the archive with ease.
Charles
Hi Charles,
Didn't know you had this! Thanks for pointing it out. Question - does it duplicate the files in the dictionary? I don't want to add bloat to my dictionary.
Thanks,
Ron
Hi Ron,
No, it uses the same table definition.
That makes it easier to maintain if you do make file changes in the future. You only need to change it in one place. That prevents your needing to keep multiple table definitions in sync.
Charles
Hi Ron,
If you are using one of the new drivers then there are 2 commands which come into play here;
MERGE
It allows the contents of one table to be pushed into another table. The destination table becomes a super-set of the source table. If a source record exists which matches any unique key in the destination table then the destination record is updated, not duplicated.
https://www.capesoft.com/docs/Driverkit/ClarionObjectBasedDrivers.htm#merge
You'll note there are two forms of this call - you can use 2 FILE structures if you have them, or a single structure using just a string as the dstination able name.) If the destination table does not exist it is created for you.
(Note: I see that there's a comment in the docs about this command being under review - I'll dig into that - as far as I know it works ok as long as the two tables are in the same database.)
Personally, I would not move "6 month old data" to the archive table. I would move all the data to the archive table. that way the arcive table is a complete record, up to now. The "main" table can then just keep the last 6 months.
Of course the concept of "archive tables" has far less meaning in SQL than in say TPS. With SQL you don't see the drop-off in performance with table size that you do in TPS.
The second command of interest to you will be DELETE(filter).
https://www.capesoft.com/docs/Driverkit/ClarionObjectBasedDrivers.htm#delete
This allows you to delete the records you no longer want (from the main table) with a single statement, and then let it execute on the server. No need to read, and delete, each row one at a time.
Cheers
Bruce