Trigger simple INSERT/UPDATE
Bonjour,
j'ai beau chercher dans tous les supports pour SQL 2008, je n'arrive pas à trouver une syntaxe de trigger comme celle que j'utilise pour Firebird:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
SET TERM ^ ;
/* Triggers only will work for SQL triggers */
CREATE TRIGGER "S_CONNECTES_BI0" FOR "S_CONNECTES"
ACTIVE BEFORE INSERT POSITION 0
AS
begin
new.dateINS = cast('NOW' as timestamp);
end
^
CREATE TRIGGER "S_CONNECTES_BU0" FOR "S_CONNECTES"
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
new.dateUP = cast('NOW' as timestamp);
end
^
COMMIT WORK ^
SET TERM ;^ |
Dans ma table S_CONNECTES j'ai deux champs, dateUP et dateIns, qui doivent être mis à jour, lors de la création pour dateINS et à chaque update dans dateUP.
merci pour votre aide, en sachant que j'ai des millions de lignes, donc il faut que ce trigger soit peu gourmand en temps.