Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Ulhas Amrite
  Where is Ulhas Amrite?
 Pune
 India
 Ulhas Amrite
 Tags
Subject: RE: Data Base Security
Thread ID: 120452 Message ID: 143771 # Views: 66 # Ratings: 0
Version: Visual FoxPro 7 Category: Databases, Tables and SQL Server
Date: Friday, August 31, 2007 2:30:32 PM         
   


> > 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)



COMPLETE THREAD
Data Base Security Posted by Ahsan Rana @ 2/1/2007 8:45:45 AM
RE: Data Base Security Posted by tushar @ 2/1/2007 8:59:56 AM
RE: Data Base Security Posted by Ahsan Rana @ 2/1/2007 12:38:58 PM
RE: Data Base Security Posted by Ken Murphy @ 2/1/2007 1:41:30 PM
RE: Data Base Security Posted by suhas hegde @ 12/20/2007 3:31:55 PM
RE: Data Base Security Posted by Frank Cazabon @ 2/1/2007 1:47:50 PM
RE: Data Base Security Posted by Boudewijn Lutgerink @ 2/1/2007 5:34:56 PM
RE: Data Base Security Posted by Ken Murphy @ 2/1/2007 5:44:05 PM
RE: Data Base Security Posted by Boudewijn Lutgerink @ 2/1/2007 5:46:21 PM
RE: Data Base Security Posted by Daniel Hofford @ 8/26/2007 3:22:47 PM
RE: Data Base Security Posted by William Sanders @ 12/19/2007 6:08:03 PM
RE: Data Base Security Posted by Andy Kramek @ 2/1/2007 11:37:49 AM
RE: Data Base Security Posted by meid lababidi @ 2/1/2007 2:47:49 PM
RE: Data Base Security Posted by Ken Murphy @ 2/1/2007 3:33:42 PM
RE: Data Base Security Posted by Tariq mehmood @ 2/6/2007 4:49:21 PM
RE: Data Base Security Posted by Boudewijn Lutgerink @ 2/7/2007 10:44:54 AM
RE: Data Base Security Posted by Tariq mehmood @ 2/7/2007 1:37:03 PM
RE: Data Base Security Posted by Ken Murphy @ 2/7/2007 2:18:30 PM
RE: Data Base Security Posted by randy loberiano @ 2/27/2008 4:05:13 AM
RE: Data Base Security Posted by Pete Sass @ 2/2/2007 3:24:02 AM
RE: Data Base Security Posted by Bernard Bout @ 2/2/2007 4:18:42 AM
RE: Data Base Security Posted by Pete Sass @ 2/10/2007 7:14:25 PM
RE: Data Base Security Posted by Bernard Bout @ 2/14/2007 5:26:58 AM
RE: Data Base Security Posted by Jamie Osborn @ 3/15/2007 1:06:09 AM
RE: Data Base Security Posted by Naomi Nosonovsky @ 3/15/2007 3:50:17 AM
RE: Data Base Security Posted by Jamie Osborn @ 3/15/2007 3:51:16 AM
RE: Data Base Security Posted by Bernard Bout @ 3/15/2007 9:15:03 AM
RE: Data Base Security Posted by Pete Sass @ 3/15/2007 1:05:09 PM
RE: Data Base Security Posted by Bernard Bout @ 3/15/2007 2:32:10 PM
RE: Data Base Security Posted by Frank Cazabon @ 3/15/2007 7:49:19 PM
RE: Data Base Security Posted by suhas hegde @ 12/19/2007 5:16:28 PM
RE: Data Base Security Posted by Prasad Sakharkar @ 2/2/2007 7:33:51 AM
RE: Data Base Security Posted by Ravi Taxali @ 2/5/2007 9:30:25 PM
RE: Data Base Security Posted by kenan cejvan @ 2/5/2007 1:27:00 PM
RE: Data Base Security Posted by mk sharma @ 3/14/2007 5:35:09 PM
RE: Data Base Security Posted by Ken Murphy @ 3/14/2007 7:26:26 PM
RE: Data Base Security Posted by mk sharma @ 3/15/2007 8:16:54 AM
RE: Data Base Security Posted by tushar @ 3/15/2007 8:29:02 AM
RE: Data Base Security Posted by mk sharma @ 3/15/2007 8:45:45 AM
RE: Data Base Security Posted by tushar @ 3/15/2007 10:45:57 AM
RE: Data Base Security Posted by Ulhas Amrite @ 8/25/2007 10:46:23 AM
RE: Data Base Security Posted by tushar @ 8/25/2007 1:18:26 PM
RE: Data Base Security Posted by Ken Murphy @ 3/15/2007 10:39:44 PM
RE: Data Base Security Posted by Ulhas Amrite @ 8/31/2007 1:31:44 PM
RE: Data Base Security Posted by Ken Murphy @ 8/31/2007 2:30:32 PM
RE: Data Base Security Posted by Jamie Osborn @ 3/15/2007 1:40:16 AM
RE: Data Base Security Posted by Bernard Bout @ 3/16/2007 2:32:21 PM
RE: Data Base Security Posted by vivek deodhar @ 8/22/2007 5:53:35 PM
RE: Data Base Security Posted by Bernard Bout @ 8/22/2007 11:40:41 PM
RE: Data Base Security Posted by vivek deodhar @ 8/23/2007 6:36:34 AM
RE: Data Base Security Posted by vivek deodhar @ 8/23/2007 9:41:35 AM
RE: Data Base Security Posted by Bernard Bout @ 8/23/2007 10:33:37 PM
RE: Data Base Security Posted by vivek deodhar @ 8/25/2007 7:16:50 AM
RE: Data Base Security Posted by Bernard Bout @ 8/27/2007 6:42:08 AM
RE: Data Base Security Posted by vivek deodhar @ 2/27/2008 5:31:57 AM
RE: Data Base Security Posted by Bernard Bout @ 2/29/2008 6:24:47 AM
RE: Data Base Security Posted by Binod Binani @ 3/15/2007 7:03:46 PM
RE: Data Base Security Posted by Kip Dole @ 12/18/2007 4:42:43 PM
RE: Data Base Security Posted by Bernard Bout @ 12/19/2007 5:53:27 AM
RE: Data Base Security Posted by Cetin Basoz @ 12/19/2007 11:40:39 AM
RE: Data Base Security Posted by Joe Estrella @ 1/9/2008 8:37:27 AM