Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Amount field
Message
 
 
To
29/12/2004 14:11:34
General information
Forum:
Microsoft SQL Server
Category:
Database management
Title:
Miscellaneous
Thread ID:
00973030
Message ID:
00973044
Views:
23
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--
Previous
Reply
Map
View

Click here to load this message in the networking platform