Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger
Message
 
 
À
07/05/2003 04:02:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00785667
Message ID:
00785888
Vues:
17
Hi Gregory,

Here is example of the trigger in SQL Server, as I promised:
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = N'tr_CartContent_Delete' 
	   AND 	  type = 'TR')
    DROP TRIGGER tr_CartContent_Delete
GO

CREATE TRIGGER tr_CartContent_Delete
ON CartContent
FOR DELETE
AS 
/*
CREATED BY:     Nadya Nosonovsky
CREATED ON:     03/03/2003
PURPOSE:        This delete triggers updates ModiType and
                LastModTs fields in Cart table, 
                when the record is deleted from the CartContent table
 */

BEGIN

UPDATE Cart
 SET LastModTs=GetDate(), ModiType = 'D'
 FROM Cart, Deleted WHERE Cart.CartID = Deleted.CartID

END

GO
-- To test
DELETE FROM CartContent WHERE CartContentID in (45,46,47)
select count(*) as Recs, CartContentID from CartDetail where CartContentID in (45,46,47) group by CartContentID
If you delete record in SQL Server -it's gone forever, there is nothing to update.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform