好的,所以我有一个相当基本的触发器:
换句话说,在插入之后,获取 IP 信息并使用新数据更新插入的行
CREATE TRIGGER [BasicData.IPInfo.Gather]
ON [BasicData]
AFTER INSERT
AS
BEGIN
DECLARE @City VARCHAR(1000),
@Country VARCHAR(1000),
@IP VARCHAR(1000),
@ROWID UNIQUEIDENTIFIER
SELECT @IP=[IP],@ROWID=[ID] FROM [inserted]
SELECT @Country = [Country], @City= [City]
FROM [IPInfo] WHERE [IP] = @IP
IF (@City IS NOT NULL) AND (@Country IS NOT NULL)
BEGIN -- Never seems to fire
UPDATE [BasicData]
SET [IPCountry]=@Country,[IPCity]=@City
WHERE [ID] = @ROWID
END
ELSE
BEGIN -- Fired correctly
INSERT INTO [IPInfo.Missing] VALUES (@IP)
END
END
现在的问题是,它正确添加了丢失的 IP 信息(仅在丢失时),但是,它似乎并没有更新表,我错过了什么?
我已经以我能想到的所有可能方式对其进行了调整......(我的触发知识相当糟糕)