Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to track user add edit delete actions in a log.dbf
Message
De
01/08/2004 09:25:58
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00929859
Message ID:
00929953
Vues:
12
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")
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform