> > Tushar is quite correct about triggers. This is what I use for my sensitive tables. There are a number of advantages to triggers, not the least of which is that your triggers work regardless of how the insert/update/delete is done. If you modify the data using your app, you need not change any of the app code. If you develop another app that uses this same data, you do not have to incorporate any new code. If you access the table using a browse window or even using somebody else's software, the trigger still works. The real advantage to triggers is that you can use them to inforce referential integrity.
If you are not familiar with the use of stored procedures and triggers, I recommend that you set aside some time and play with them.>
> > Ken
> > You shall know the truth - and the truth shall set you free. (John 8:33)
>
> Dear Ken,
>
> Well I am not familiar with stored procedures. Can you please elaborate?
>
> Regards,
> Ulhas Amrite
Ulhas,
A stored procedure is simply a function or procedure that is stored in the database container. Lets say that you wanted to create a funtion that would display "hello world" on your form. Normally you would create this function in a procedure file (in a .prg.):
PROCEDURE HelloWorld
WAIT WINDOW [Hello World] TIMEOUT 3
ENDPROC
When you do this in a procedure file, you need to SET PROCEDURE TO that procedure file. You can do the exact same thing in a database stored procedure. The database acts as the procedure file and if the database is open, you can access the stored procedures in it.
The big advantage to stored procedures is that you can associate them with triggers. For example, let's say you are trying to create a record change log. Each time a record is saved, inserted or deleted, you want to identify that change in a log. You have a procedure like this:
PROCEDURE LogThisChange
LPARMETERS tcUserName, tnRecordID, tcChangeType
INSERT INTO MyLog VALUES (tcUserName, tnRecordID, tcChangeType)
ENDPROC
In your table you create a series of triggers. The Insert trigger might be:
LogThisChange(GETENV([USERNAME]),MyTable.RecordID,[Insert])
The key here is that the LogThisChange procedure is located in the database. If the database is open, then the procedure can be used (no need to SET PROCEDURE TO.) If the table is open, so is the database. In other words, if a record is being inserted, the table must be open. If the table is open, so must the database. If the database is open, so are the stored procedures so you can use them.
Hope this helps
Ken
You shall know the truth - and the truth shall set you free. (John 8:33)