Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create a Trigger for delete
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00230489
Message ID:
00230723
Vues:
26
>I need to create a trigger for delete and execute an stored procedure to insert in another table how has delete, what form and date.
>
>Who can help me with this.
>
>Is there a way to do it for all the tables in a database?
>
>Thanks in advance.

To specify a procedure to run when a record is deleted in a table, click on the table tab in the table designer (dbc contained tables only), and put the name of the procedure in the delete trigger box: MyDeleteRoutine(). You'll want to create this routine as a dbc stored procedure so it is always available to the table.

As far as specifying who deleted the record, and what form did it, that gets a little trickier. You could put some code put some code in your trigger like:

IF TYPE("_SCREEN.ActiveForm.Name") = "C"
lcFormName = _SCREEN.ActiveForm.Name
ELSE
lcFormName = ""
ENDIF
* grab the user name from the system
lcUserName = SUBSTR(SYS(0), RAT("#", SYS(0)) + 1)

ltDeletedTime = DATETIME()
lcTable = ALIAS()
INSERT INTO DELETELOG (User, Form, Deleted, Table) VALUES (lcUsername, lcFormName, ltDeletedTime, lcTable)

to do this for every table in the database, you would have to specify this procedure in every table.
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform