我刚刚从mssql迁移到mysql,我正在使用插入触发器。现在我想将我的mssql服务器触发器脚本转换为mysql。有什么帮助吗?
CREATE TRIGGER trgAutoInsert
ON dbo.profile
AFTER INSERT
AS
DECLARE @var1 int ,@var2 int ,@var3 char (100) ,@var4 char (100) , @var5 char (3)
select @var1 = profile_id, @var2 = profile_id, @var3 = fname , @var4 = fname ,@var5 = fpage
From profile
BEGIN
IF @var5 = 'yes'
INSERT INTO friends (req_id,resp_id,req_name,resp_name,fpage)
VALUES (@var1,@var2,@var3,@var4,'yes')
答案 0 :(得分:0)
CREATE TRIGGER trgAutoInsert AFTER INSERT ON t1
FOR EACH ROW
BEGIN
DECLARE var1 INT;
DECLARE var2 INT;
DECLARE var3 CHAR(100);
DECLARE var4 CHAR(100);
DECLARE var5 CHAR(3);
SELECT profile_id,
profile_id,
fname,
fname,
fpage
FROM profile
INTO var1,
var2,
var3,
var4,
var5;
IF var5 = 'yes'
THEN
INSERT INTO fiends
(req_id, resp_id, req_name, resp_name, fpage)
VALUES
(var1, var2, var3, var4, 'yes');
END IF;
END
也许这个?