Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Amount field
Message
 
 
À
29/12/2004 14:11:34
Sergio Ortiz
Tek Services Group, Llc
Hollywood, Floride, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Maintenance bases de données
Titre:
Divers
Thread ID:
00973030
Message ID:
00973044
Vues:
21
Hi Sergio,

It's not correct. In triggers you work with special Deleted and Inserted tables which represent records state before and after update. Obviously, there is no Deleted record for INSERT and no Inserted record for DELETE. In your case you would join INSERTED table with trnsaction table for UPDATE statement.
Also you have to take in account that trigger may be called recursively if you issue UPDATE statement from the trigger. You'll have to check for that too.

>Here is the triggers,
>it seems to be working fine
>
>
>CREATE TRIGGER amount ON [dbo].[trnsaction]
>FOR INSERT, UPDATE
>AS
>DECLARE @type int
>
>SELECT @type = tcodeid FROM trnsaction
>IF @type = 1
>UPDATE trnsaction   SET amount = -amount
>
>
>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform