Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trigger
Message
 
 
To
07/05/2003 04:02:28
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00785667
Message ID:
00785888
Views:
19
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform