Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I do this trigger?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01044125
Message ID:
01044395
Vues:
9
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform