1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| CREATE TRIGGER modif_contact
ON contact
FOR INSERT, UPDATE, DELETE
AS
DECLARE @code char(8);
-- c'est ici que j'ai des problèmes
SELECT @code = CT_CODE
FROM CONTACT
print(@code);
--
DECLARE @rowInsert int, @rowDelete int;
SELECT @rowInsert = count(*)
FROM INSERTED
SELECT @rowDelete = count(*)
FROM DELETED
if @rowInsert<>0
begin
print('inserted');
INSERT INTO historique
VALUES(@code,'contact','insert');
return;
end
else
print('compte deleted');
if @rowDelete<>0
begin
print('deleted');
INSERT INTO historique
VALUES(@code,'contact','delete');
return;
end
else
print('update');
INSERT INTO historique
VALUES(@code,'contact','update');
return;
print @code |
Partager