Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to track user add edit delete actions in a log.dbf
Message
From
01/08/2004 09:25:58
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00929859
Message ID:
00929953
Views:
14
Hi Soykan.

would you like to expand this matter with a sample if its possible...

PMFJI, but what Viv means is that you create a table called log.dbf that has a structure similar to this:

TableName C( 20 )
FieldName C( 20 )
OldValue M
NewValue M

Then you create, for example an update trigger called LogUpdate in your dbc with code similar to this:
PROCEDURE LogUpdate
LPARAMETERS tcTable
LOCAL lnFields, laFields[ 1 ], lnI, lcFieldName
IF NOT USED( 'LogFile' )
  USE logFile IN 0
ENDIF
lnFields = AFIELDS( laFields, tcTable )
FOR lnI = 1 TO lnFields
  lcFieldName = ALLTRIM( laFields[ lnI, 1 ] )
  IF GETFLDSTATE( lcFieldName, tcTable ) = 2
	INSERT INTO LogFile ( TableName, FieldName, OldValue, NewValue ) VALUES ( tcTable, lcFieldName, TRANSFORM( OLDVAL( lcFieldName, tcTable ) ), TRANSFORM( EVALUATE( tcTable + [.] + lcFieldName ) ) )
  ENDIF
ENDFOR
Then, on the table that you want to log, you specify this as its update trigger under the table tab of the table designer:
logupdate("MyTable")
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform