Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Olaf Doschke
  Where is Olaf Doschke?
 Hamburg
 Germany
 Olaf Doschke
 To: subhankar pandey
  Where is subhankar pandey?
 Kolkata/Delhi
 India
 subhankar pandey
 Tags
Subject: RE: How to prevent to modify record
Thread ID: 155246 Message ID: 155302 # Views: 2 # Ratings: 0
Version: Visual FoxPro 8 Category: Databases, Tables and SQL Server
Date: Saturday, December 29, 2007 1:10:12 PM         
   


> Dear Olaf,
> Yr 1st idea pertating to logical field 'Im working on it, but however yr 2nd idea is not yet clear to me I mean to say "SYS(2017)....", would request to provide some sort example(code) to enable me to proceed.
>
> Sorry If I'm giving trouble

No, you're not giving trouble.

No wonder SYS(2017,...) did not work for you, as additional parameters were
added in VFP9 only.

But I suggested three ideas. Let me perhaps explain the ideas non technical first:

All three ideas can't technically prevent changes in printed records,
there will always be ways to change records anyway, as you technically
can only make a whole file readonly, not single records.

1) you add the information to printed records, that they are printed.
This alone will not make a record readonly, you need to write code preventing
changes to records marked printed.

This is quite easy to implement, just need an addtional field in the table,
set it to .T. when printing, check the value before allowing editing.

To prevent editing or deleting you ideally put that code in stored procs
that are called by update- and delete-trigger, that is the most central
way to catch all situations where records are changed, even when you
browse in the table and work within the IDE outside of your program logic.

For that to work the DBFs need to be tables of a DBC, otherwise you have no
triggers available, that run automatically for each update- or delete-
manipulation whatsoever. Within a DBC table you can define such trigger
that run before the insert, update and/or delete of a record and allow
or disallow the operation.

2) you add a checksum information to the records. That way you can detect
changes by a) storing the checksum computed at printout time and b) computing
the checksum again at any later time and check, wheter it has changed compared
to the checksum calculated at printout time. That does however not tell you
what has changed.

You can do that as an additional help to detect changes, especially if
your dbfs are not tables of a DBC.

You're not bound to use SYS(2017) as I suggested, you can use any
method, that will calculate a checksum from the data of the record.

3) log data, that is copy all versions of a record to a log file or log
table.

This is the most secure thing, as you can always restore the record the
way it was, as it was printed. If you do this additional to adding a field
l printed (1), you can search the first occurance of the record with that
field being .T.

Again, ideally this is done in triggers/stored procs for a DBC table.
A log of the records is in general helpful, if you want to know what
versions of each record existed and be able to restore a version.

Bye, Olaf.

ENTIRE THREAD

How to prevent to modify record Posted by subhankar pandey @ 12/28/2007 1:20:53 PM
RE: How to prevent to modify record Posted by Mike Gagnon @ 12/28/2007 1:59:13 PM
RE: How to prevent to modify record Posted by Ken Murphy @ 12/28/2007 2:00:27 PM
RE: How to prevent to modify record Posted by subhankar pandey @ 12/29/2007 8:43:59 AM
RE: How to prevent to modify record Posted by Olaf Doschke @ 12/29/2007 12:45:49 PM
RE: How to prevent to modify record Posted by subhankar pandey @ 12/31/2007 6:22:15 AM
RE: How to prevent to modify record Posted by Ken Murphy @ 12/29/2007 1:23:50 PM
RE: How to prevent to modify record Posted by subhankar pandey @ 12/31/2007 6:20:37 AM
RE: How to prevent to modify record Posted by Olaf Doschke @ 12/28/2007 10:55:48 PM
RE: How to prevent to modify record Posted by subhankar pandey @ 12/29/2007 8:57:01 AM
RE: How to prevent to modify record Posted by Olaf Doschke @ 12/29/2007 1:10:12 PM
RE: How to prevent to modify record Posted by subhankar pandey @ 12/31/2007 6:24:55 AM