我有这个触发器(而不是插入),这是为常规SQL,我正试图把它变成MySQL,这是我所得到的:
Create Trigger trGenerateNpcID
Before Insert On NPC For Each Row
Begin
Declare Race varchar(5);
Declare Name varchar(25);
Declare Level int;
Declare Class1 varchar(5);
Declare Class2 varchar(5);
Declare City varchar(5);
Set Race = (Select Race From Inserted);
Set Name = (Select Name From Inserted);
Set Level = (Select Level From Inserted);
Set Class1 = (Select Class1 From Inserted);
Set Class2 = (Select Class2 From Inserted);
Set City = (Select City From Inserted);
Insert into NPC
Values(Left(Race, 1) + Left(Name, 1) + Left(Level, 1) + next value for sqNpcID,
Name, Race, Level, Class1, Class2, City);
End;
每次我试着去做,它都会给我这个错误:
1064-SQL语法中有错误;查看与您的MariaDB服务器版本对应的手册,了解在第4行""附近使用的正确语法
我会很感激你的任何帮助。
1条答案
按热度按时间j8ag8udp1#
它应该起作用: