>Does anyone have any recommendations for good UT files to do this? There seem to be so many there. I'm looking for a way to track changes to data, b/c I suspect "unauthorized" people are trying to look at my tables.
Here is a very simple SP we use for just that... you need to put a call in the trigger for each table you want to track,
ex. Insert trigger = sptranslog("MENUTABLE","INSERT")
FUNCTION spTransLog
LPARAMETERS tcalias,tcaction
* if doing a bulk file copy, dimension a variable called glbulkcopy and assign it .T.
* this wil ignore the stored procedure
IF VARTYPE( glbulkfilecopy ) = "L" AND glbulkfilecopy = .T.
RETURN .T.
ELSE
IF USED(tcalias) && Put in to check for direct table name reference
SELECT (tcalias)
ENDIF
SCATTER TO latransaction
lnfields = ALEN(latransaction) && Used for _changed field
* See if a transaction log is in the database
* if not, create it
IF NOT INDBC(tcalias+"_TRAN","TABLE")
SELECT *, SPACE(15) AS _cuser ,DATETIME() AS _Timestamp ,SPACE(10) AS _caction, SPACE(lnfields+ 1) AS _changed;
from (tcalias) WHERE .F. INTO TABLE (ADDBS(JUSTPATH(DBC())) +tcalias+"_TRAN") DATABASE icams
USE
ENDIF
IF USED(tcalias)
SELECT (tcalias)
ENDIF
* Add transaction information to the table
DIMENSION latransaction(lnfields+4)
latransaction(lnfields+1) = setdefaultvalue("oapp.ouser.cinitials",SYS(0)) && Changed 4/4/00 JSH to include full network path
latransaction(lnfields+2) = DATETIME()
latransaction(lnfields+3) = UPPER(tcaction)
IF cursorgetprop("buffering") > 1 && Changed 4/4/00 JSH for direct fox use. Getfldstate requires buffering
latransaction(lnfields+4) = GETFLDSTATE(-1,ALIAS()) && function shows what fields changed
ELSE
latransaction(lnfields+4) = "No Buffering "+TRAN( cursorgetprop("buffering"))
ENDIF
* Insert the transaction into the log
INSERT INTO (tcalias+"_TRAN") FROM ARRAY latransaction
ENDIF
RETURN .T.
Wayne Myers, MCSD
Senior Consultant
Forte' Incorporated
"The only things you can take to heaven are those which you give away" Author Unknown