Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I do this trigger?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01044125
Message ID:
01044395
Views:
10
I tested code before posting it and it didn't generate any errors. You've to provide more details on what you're doing and how.

>It's firing an error message:"Row cannot be located for updating. Some values may have been changed since it was last read".
>
>
>
>>Try
CREATE TRIGGER utr_Detalle_Insert
>>ON Detalle
>>FOR INSERT
>>AS
>>BEGIN
>>	INSERT INTO Balance (Cuenta, Periodo, Fiscal, Balance)
>>		SELECT Cuenta, Periodo, Fiscal, 0 FROM INSERTED
>>			WHERE NOT EXISTS( SELECT * FROM Balance
>>					WHERE Balance.Cuenta = INSERTED.Cuenta
>>						AND Balance.Periodo = INSERTED.Periodo
>>						AND Balance.Fiscal = INSERTED.Fiscal)
>>
>>	UPDATE Balance
>>		SET Balance = Balance + INSERTED.Credito - INSERTED.Debito
>>	FROM Balance
>>	JOIN INSERTED ON Balance.Cuenta = INSERTED.Cuenta
>>		AND Balance.Periodo = INSERTED.Periodo
>>		AND Balance.Fiscal = INSERTED.Fiscal
>>
>>END
>>GO
>>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform