Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add Date/Time stamp to tables in dbc.
Message
From
09/03/1999 20:49:37
Susan Giddings
Aar Engine Component Services
Windsor, Connecticut, United States
 
 
To
08/03/1999 23:11:59
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00195409
Message ID:
00195668
Views:
12
Thanks Erik, I thought there would be a problem with the deleted records. I can easily enough add a "deletelog" to the system as you suggest.

>>Is there an easy or preferred way to maintain a date/time stamp field in a table (in a dbc)? I want to record the last date/time that a record is modified (which includes a delete). All my tables already have a date/time field and I do have a default value coming in when a record is added, but I need it updated whenever the record changes & I'm not sure where the best place to put this is. I'm thinking that it's better to be in the dbc as a record validation rule, but I'm already using those on many tables. I hate to write a ton of procedures to call two validation rules, but I will if I have to. The only alternative I can think of is to add the code to the class for the save push button, but for some reason I'm thinking that's not the cleanest and safest way to manage it. Any suggestions or tips?
>>TIA, Susan
>
>Most of this is easy. Create a procedure in your dbc called TimeStamp().
>
>FUNCTION TimeStamp
>IF TYPE('TimeStamp') = "T"
>REPLACE TimeStamp WITH DATETIME()
>ENDIF
>ENDFUNC
>
>and then put TIMESTAMP in your record validation rule. If you have a field called timestamp in your table, it will be updated with the current datetime when the record is changed.
>If you have other record validations rules for sme tables, put MyOtherRule() AND TimeStamp() in the rule.
>
>
>The hard part comes in trying to update the timestamp when the record is deleted. Two facts get in the way: 1. Validation rules don't run when you delete a record. This is by design; you shouldn't have to validate the contents of deleted records. 2. You cannot update the contents of a record from within a trigger. So you can't call the timestamp function from the delete trigger. This is also by design and is so you don't get yourself into an infinite loop.
>
>I have found no way to handle this in the dbc. The alternative we are using is an external 'deletelog' table that stores the Tablename, PK and Timestamp of records that were deleted. This table is populated with a stored procedure called from the delete trigger of each table.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform