Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger
Message
De
08/05/2003 04:28:11
 
 
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:
00786112
Vues:
19
Hi Nadya,

As far as I can see, the dates are kept in another table.

This can be done in vfp as well. Although no change can be done to the record that caused the trigger to fire, you can do all sorts of things in other tables. The mods in the other tables may then fire other triggers

eg consider 4 tables: Task, TaskHistory, Employee and Roster (employee)

An entry in TaskHistory has an Emp_id, StartTime, EndTime and TotalTime (=EndTime-StartTime) in seconds

Any change in TaskHistory updates the Roster (Emp, Year, Week, Date, SecondsWorked)

At the end of each day the Roster is compared with the TotalTime an employee was expected to work, and if less than expected a mail is sent to the employee

Of course, one may argue that a view would do the job just as well


>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.
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform