Tutorials to .com

Tutorials to .com » Software » Vfp » VFP table tracking method

VFP table tracking method

Print View , by: iSee ,Total views: 44 ,Word Count: 2119 ,Date: Sat, 18 Apr 2009 Time: 8:08 PM


Abstract This paper introduces the Visual foxpro database to trigger the application of technology, in order to establish a tracking log vfp table to provide multi-user environment to resolve the network data files in a method of security.
Key words trigger technology, table tracking, tracking table-defined functions of the problem:
In the management of the normal operation of information systems, information security issues have become increasingly prominent. Although the network has provided us with a certain degree of data security, only authorized users can carry out day-to-day maintenance of data, but sometimes the user's misoperation could cause data loss or confusion; In addition, sometimes we need to leave a record of data changes and so on. Of important data files to record changes in each of the audit log data, the establishment of its corresponding log sheet to keep track of it by, delete and modify the operation is necessary. The log table records the when, where what the user operation, recorded by the user to add or remove any record of information, as well as the original record is modified and the revised information will be manipulated to back up off the record.
VFP trigger Technology:
Visual Foxpro and its preliminary version of one of the major differences is the use of the database (Database) the power to become a real DataBase. VFP the database Container contains a table (Table) and the definition of the table a variety of attributes, but also belonging to the SQL back-end technology of the trigger (Trigger).
Trigger for the Database in the use of the Table provides a record-level rules (that is, testing procedures). Trigger into Insert Trigger, Update Trigger and three operating Delete Trigger. Insert Trigger for the Table Add record when triggered by the detection program, Update Trigger for the Table to amend records kept by the trigger back to the testing process, Delete Trigger for the Table in the record was deleted by the trigger of the testing process. VFP allow any operation to set different rules, which can be expressions or user-defined function (UFD), if the true value in response to that trigger successful, false if the response value, that triggered the failure. User-defined function (UFD) in stored in the Database Container.
There are two ways to create a trigger:
1) Open the Table Properties "dialog box, in the INSERT, UPDATE or DELETE trigger box, enter the trigger expressions or user-defined function (UFD);
2) the use of CREATE TRIGGER command.
Create, edit, or remove the storage process in three ways:
1) In project management, select and start a database, select "stored procedure", and then select "New", "modify" or "remove" button;
2) in the database designer from the "Database" menu, select "Edit Stored Procedures" button;
3) in the COMMAND command window, use the command MODIFY PROCEDURE.
Table tracking design:
The use of Insert Trigger, Update Trigger and Delete Trigger three operating principles, we can construct being manipulated records to back up user-defined function, and its accession to the need for follow-up data files table Trigger in order to achieve the tracking table. In this way, regardless of the user to use the procedures of manipulation of this table or directly open the table and modify the records of additions and deletions can be manipulated to stimulate Trigger will be recorded in the log records.
I constructed four common self-defined functions, Inslog (), Dellog (), Modlog () and addlog (), deposited in the Database Container storage process. The need for tables in the data files tracking Insert Trigger, Delete Trigger and Update Trigger joined in Inslog () function, Dellog () function and Modlog () function, so that the data recorded by the document, delete and modify both the excitation Trigger for the log records. addlog () has been used to create the log table to track table structure, the structural design of the log table has been tracking table contains all the field information, and increase the user signs opid, Date Time optime operations and field operations opmak signs. Log table for the naming of the table track the table before the 'L', to show the distinction, and I store data files in a separate subdirectory under the directory LOGDBFS, dedicated to the storage to manage the log table. Programming the four functions are as follows:

* Insert Trigger:
FUNCTION inslog ()
m.path = substr (dbf (), 1, rat ( '\', dbf ()))
m. logname = m.path + 'LOGDBFS \ L' + SUBSTR (DBF (), LEN (m.path) +1)
IF NOT FILE (m.logname)
= addlog () & & set up the log table structure
ENDI
SCATTER MEMVAR
m.opmak = 'by' & & increased record mark
m.opid = SYS (0) & & check mark users
m.optime = datetime () & & to increase recording time
INSERT INTO (m.logname);
FROM MEMVAR & & documented by the records
RETURN. T.

* Delete Trigger:
FUNCTION dellog ()
m.path = substr (dbf (), 1, rat ( '\', dbf ()))
m. logname = m.path + 'LOGDBFS \ L' + SUBSTR (DBF (), LEN (m.path) +1)
IF NOT FILE (m.logname)
= addlog ()
ENDI
SCATTER MEMVAR
m.opmak = 'delete' & & delete records logo
m.opid = SYS (0)
m.optime = datetime ()
INSERT INTO (m.logname);
FROM MEMVAR & & delete records by record
RETURN. T.

* Update Trigger:
FUNCTION modlog ()
m.path = substr (dbf (), 1, rat ( '\', dbf ()))
m. logname = m.path + 'LOGDBFS \ L' + SUBSTR (DBF (), LEN (m.path) +1)
IF NOT FILE (m.logname)
= addlog ()
ENDI
DIME alog [FCOUNT () +3]
alog [FCOUNT () +2] = SYS (0)
alog [FCOUNT () +3] = datetime ()
alog [FCOUNT () +1] = 'amendment (former)'
FOR i = 1 TO FCOUNT ()
alog [I] = oldval (field [I])
ENDFOR
INSERT INTO (m.logname);
FROM ARRAY alog & & recorded before the change of information
alog [FCOUNT () +1] = 'amendments (now)'
FOR i = 1 TO FCOUNT ()
alog [I] = EVALUATE (field [I])
ENDFOR
INSERT INTO (m.logname);
FROM ARRAY alog & & record information changes
RETURN. T.

* The establishment of the log table structure:
FUNCTION addlog ()
* Table to be tracked from the field
COPY STRU TO tmp EXTEND
* The establishment of a user signs, operation time and operation of the field of information signs
INSERT INTO tmp.dbf;
(field_name, field_type, field_len);
VALUES ( 'OPMAK', 'C', 6)
INSERT INTO tmp.dbf;
(field_name, field_type, field_len);
VALUES ( 'OPID', 'C', 10)
INSERT INTO tmp.dbf;
(field_name, field_type, field_len);
VALUES ( 'OPTIME', 'T', 8)
USE IN tmp
oldselect = SELECT () & & generate a log table structure
SELE 0
CREATE (m.logname) FROM tmp
DELETE FILE tmp.dbf
SELECT (oldselect)
RETURN


Visual FoxPro Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.