Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Declaring variable for current record
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
00995317
Message ID:
00995324
Vues:
15
Sergey,

How would you solve this situation?

Table Test

ID DESCRIPTION DEFAULT
1 Apple 0
2 Banana 0
3 Carrot 0
4 Citrus 1



When updating record ID = 1 (Apple) and assigning DEFAULT = 1

I wanted an UPDATE trigger to reset all other records with DEFAULT = 1 (Citrus) Except the one I'm updating (Apple).



>Luc,
>
>There's no current record in a trigger. A trigger is fired once per SQL statement regardless how many records are affected by such statement. The info about affected records is presented in a trigger in two special tables: DELETED and INSERTED. Keep also in mind, that triggers could fire recursively if DB setting allow it.
>
>>I've been searching the BOL for a clue without sucess...
>>
>>In a trigger,
>>how can I declare a variable for the current record?
>>
>>I want a trigger to fire on an INSERT or an UPDATE.
>>
>>
>>DECLARE @ID_CurrentRecord Int
>>
>>@ID_CurrentRecord= <<Table.ID_Field>>              && Current Value
>>
>>UPDATE Table SET Somefield = SomeValue WHERE Table.ID_Field <> @ID_CurrentRecord
>>
Luc Nadeau
lnadeau@neova.ca

"the theory, it is when all is known and that nothing works. The practice, it is when all works and that nobody knows why." - Albert Einstein (Nobel of physique 1921)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform