错误代码:1241。操作数应在更新和触发器上包含1列
我有一个足球数据库,并且我有一个触发器(notas),该触发器正在计算他的统计数据后的播放器评级,我可以创建触发器,但是当我更新播放器统计数据时,它会给我带来错误代码:1241
(我的更新位于表Jogadoresestatísticasbrutas中,但这是因为还有其他触发器,并且在表Jogadoresestatísticasporjogo上触发了插入统计数据,经过一些测试,我发现问题在触发trigger notas notas notas notas 。)
DELIMITER //
CREATE TRIGGER Notas
AFTER UPDATE ON JogadoresEstatísticasPorJogo
FOR EACH ROW
begin
set @Nome = new.Nome;
set @GolsPJN = new.GolsPJ;
set @AstPJN = new.AssistsPJ;
set @PreAstPJN = new.PréAstPJ;
set @GrandesChancesCriadasPJN = new.GrandesChancesCriadasPJ;
set @GrandesChancesErradasPJN = new.GrandesChancesErradasPJ;
set @PassesTentadosPJN = new.PassesTentadosPJ;
set @PassesCompletosPJN = new.PassesCompletosPJ;
set @PorcentagemPassesPJN = new.PorcentagemPassesPJ;
set @DriblesTentadosPJN = new.DriblesTentadosPJ;
set @DriblesCompletosPJN = new.DriblesCompletosPJ;
set @ChutesTentadosPJN = new.ChutesTentadosPJ;
set @ChutesNoGolPJN = new.ChutesNoGolPJ;
set @ChutesBloqueadosPJN = new.ChutesBloqueadosPJ;
set @PerdadePossePJN = new.PerdadePossePJ;
set @DesarmesCompletosPJN = new.DesarmesCompletosPJ;
set @TentativasSofridasdeDriblePJN = new.TentativasSofridasdeDriblePJ;
set @DriblesSofridosPJN = new.DriblesSofridosPJ;
set @BloqueiosPJN = new.BloqueiosPJ;
set @InterceptacoesPJN = new.InterceptaçõesPJ;
set @DuelosAereosGanhosPJN = new.DuelosAéreosGanhosPJ;
set @DuelosAereosPerdidosPJN = new.DuelosAéreosPerdidosPJ;
set @FaltasCometidasPJN = new.FaltasCometidasPJ;
set @GolsNotas = @GolsPJN * 25;
set @GrandesChancesErradasNotas = (@GolsPJN - @GrandesChancesErradasPJN) * 17;
set @DriblesNotas = @DriblesCompletosPJN / @DriblesTentadosPJN * 2;
set @ChutesNotas = @ChutesnoGolPJN / @ChutesTentadosPJN * 15;
set @PerdadePosseNotas = @PerdadePossePJN / (@PassesTentadosPJN + @DriblesTentadosPJN) * (-65);
set @AstNotas = @AstPJN * 25;
set @PreAst = @PreAstPJN * 50;
set @GrandesChancesCriadas = @GrandesChancesCriadasPJN / @PassesCompletosPJN * 60;
set @PorcentagemNotas = @PorcentagemPassesPJN / 10 * 1.50;
set @DesarmesNotas = @DesarmesCompletosPJN * 25;
set @DriblesSofridosNotas = (10 - (@DriblesSofridosPJN / @TentativasSofridasdeDriblePJN * 3,5)) *2;
set @FaltasCometidasNotas = @FaltasCometidasPJN * (-8);
set @BloqueiosInterceptacoesNotas = (@BloqueiosPJN * 2 + @InterceptacoesPJN * 7) *3;
set @NotaOfensiva = truncate ((@GolsNotas + @GrandesChancesErradasNotas + DriblesNotas + ChutesNotas + PerdadePosseNotas) / 10 , 2);
set @NotaCriacao = truncate ((@AstNotas + @PreAst + @GrandesChancesCriadas + @PorcentagemNotas) / 10, 2);
set @NotaDefensiva = truncate ((@DesarmesNotas + @DriblesSofridosNotas + @FaltasCometidasNotas + @BloqueiosInterceptacoesNotas) / 10 , 2);
set @NotaGeral = (@NotaOfensiva + @NotaCriacao + @NotaDefensiva) / 3;
update JogadoresNotas set NotaOfensiva = @NotaOfensiva where Nome = @Nome;
update JogadoresNotas set NotaCriação = @NotaCriacao where Nome = @Nome;
update JogadoresNotas set NotaDefensiva = @NotaDefensiva where Nome = @Nome;
update JogadoresNotas set NotaGeral = @NotaGeral where Nome = @Nome;
end //
DELIMITER ;
我的更新:
DELIMITER // begin
Update JogadoresEstatísticasBrutas SET Nome = 'R', Jogos = "7", Gols = "3", Assists = "5", PréAst = "0", GrandesChancesCriadas = "10", GrandesChancesErradas = "4", PassesTentados = "65", PassesCompletos = "55", PorcentagemPasses = "84", DriblesTentados = "18", DriblesCompletos = "11", ChutesTentados = "7", ChutesNoGol = "5", ChutesBloqueados = "1", PerdadePosse = "13", DesarmesCompletos = "6", TentativasSofridasdeDrible = "8", DriblesSofridos = "4", Bloqueios = "10", Interceptações = "4", DuelosAéreosGanhos = "1", DuelosAéreosPerdidos = "0", FaltasCometidas = "2", FaltasSofridas = "2", ChutesSofridos = "6", Defesas = "3", ChutesDifíceis = "3", DefesasDifíceis = "0" where Nome = "R";
Update JogadoresEstatísticasBrutas SET Nome = 'N', Jogos = "7", Gols = "3", Assists = "2", PréAst = "1", GrandesChancesCriadas = "5", GrandesChancesErradas = "4", PassesTentados = "37", PassesCompletos = "29", PorcentagemPasses = "78", DriblesTentados = "12", DriblesCompletos = "6", ChutesTentados = "10", ChutesNoGol = "5", ChutesBloqueados = "0", PerdadePosse = "8", DesarmesCompletos = "3", TentativasSofridasdeDrible = "11", DriblesSofridos = "7", Bloqueios = "3", Interceptações = "0", DuelosAéreosGanhos = "1", DuelosAéreosPerdidos = "0", FaltasCometidas = "4", FaltasSofridas = "2", ChutesSofridos = "9", Defesas = "7", ChutesDifíceis = "2", DefesasDifíceis = "1" where Nome = "N";
Update JogadoresEstatísticasBrutas SET Nome = 'B', Jogos = "7", Gols = "6", Assists = "3", PréAst = "1", GrandesChancesCriadas = "4", GrandesChancesErradas = "6", PassesTentados = "54", PassesCompletos = "48", PorcentagemPasses = "88", DriblesTentados = "22", DriblesCompletos = "14", ChutesTentados = "25", ChutesNoGol = "10", ChutesBloqueados = "7", PerdadePosse = "14", DesarmesCompletos = "7", TentativasSofridasdeDrible = "10", DriblesSofridos = "6", Bloqueios = "4", Interceptações = "5", DuelosAéreosGanhos = "0", DuelosAéreosPerdidos = "3", FaltasCometidas = "4", FaltasSofridas = "4", ChutesSofridos = "7", Defesas = "4", ChutesDifíceis = "5", DefesasDifíceis = "2" where Nome = "B";
Update JogadoresEstatísticasBrutas SET Nome = 'F', Jogos = "7", Gols = "8", Assists = "1", PréAst = "1", GrandesChancesCriadas = "6", GrandesChancesErradas = "3", PassesTentados = "55", PassesCompletos = "40", PorcentagemPasses = "72", DriblesTentados = "18", DriblesCompletos = "10", ChutesTentados = "17", ChutesNoGol = "7", ChutesBloqueados = "4", PerdadePosse = "10", DesarmesCompletos = "9", TentativasSofridasdeDrible = "19", DriblesSofridos = "7", Bloqueios = "14", Interceptações = "3", DuelosAéreosGanhos = "0", DuelosAéreosPerdidos = "0", FaltasCometidas = "2", FaltasSofridas = "3", ChutesSofridos = "13", Defesas = "9", ChutesDifíceis = "7", DefesasDifíceis = "3" where Nome = "F";
Update JogadoresEstatísticasBrutas SET Nome = 'G', Jogos = "7", Gols = "9", Assists = "1", PréAst = "1", GrandesChancesCriadas = "6", GrandesChancesErradas = "5", PassesTentados = "52", PassesCompletos = "44", PorcentagemPasses = "84", DriblesTentados = "8", DriblesCompletos = "1", ChutesTentados = "29", ChutesNoGol = "21", ChutesBloqueados = "6", PerdadePosse = "11", DesarmesCompletos = "5", TentativasSofridasdeDrible = "15", DriblesSofridos = "9", Bloqueios = "9", Interceptações = "5", DuelosAéreosGanhos = "1", DuelosAéreosPerdidos = "0", FaltasCometidas = "0", FaltasSofridas = "2", ChutesSofridos = "5", Defesas = "2", ChutesDifíceis = "3", DefesasDifíceis = "1" where Nome = "G";
Update JogadoresEstatísticasBrutas SET Nome = 'D', Jogos = "7", Gols = "4", Assists = "0", PréAst = "1", GrandesChancesCriadas = "6", GrandesChancesErradas = "7", PassesTentados = "55", PassesCompletos = "51", PorcentagemPasses = "92", DriblesTentados = "12", DriblesCompletos = "6", ChutesTentados = "19", ChutesNoGol = "13", ChutesBloqueados = "4", PerdadePosse = "10", DesarmesCompletos = "9", TentativasSofridasdeDrible = "22", DriblesSofridos = "12", Bloqueios = "8", Interceptações = "1", DuelosAéreosGanhos = "0", DuelosAéreosPerdidos = "0", FaltasCometidas = "3", FaltasSofridas = "0", ChutesSofridos = "3", Defesas = "1", ChutesDifíceis = "2", DefesasDifíceis = "1" where Nome = "D";
end; DELIMITER;
表jogadoresestatísticasbrutas和jogadoresnotas
CREATE TABLE IF NOT EXISTS JogadoresEstatísticasBrutas (
IdJogadores INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Nome VARCHAR(40) NULL,
Jogos INT NULL,
Gols INT NULL,
Assists INT NULL,
PréAst INT NULL,
GrandesChancesCriadas INT NULL,
GrandesChancesErradas INT NULL,
PassesTentados INT NULL,
PassesCompletos INT NULL,
PorcentagemPasses INT NULL,
DriblesTentados INT NULL,
DriblesCompletos INT NULL,
ChutesTentados INT NULL,
ChutesNoGol INT NULL,
ChutesBloqueados INT NULL,
PerdadePosse INT NULL,
DesarmesCompletos INT NULL,
TentativasSofridasdeDrible INT NULL,
DriblesSofridos INT NULL,
Bloqueios INT NULL,
Interceptações INT NULL,
DuelosAéreosGanhos INT NULL,
DuelosAéreosPerdidos INT NULL,
FaltasCometidas INT NULL,
FaltasSofridas INT NULL,
ChutesSofridos INT NULL,
Defesas INT NULL,
ChutesDifíceis INT NULL,
DefesasDifíceis INT NULL);
CREATE TABLE IF NOT EXISTS JogadoresNotas (
IdJogadores INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Nome VARCHAR(40) NULL,
Jogos INT NULL,
NotaOfensiva FLOAT (3, 2) NULL,
NotaCriação FLOAT (3, 2) NULL,
NotaDefesinva FLOAT (3, 2) NULL,
NotaGeral FLOAT (4, 2) NULL);
I Have a soccer database, and I have a trigger (notas) that is calculating a player rating after the insert of his stats, I am able to create the trigger, but when I update the player stats it gives me Error Code: 1241
(My update is in Table JogadoresEstatísticasBrutas, but is because there is other trigger working, and that trigger insert stats on Table JogadoresEstatísticasPorJogo, After some tests I discovered that the problem is in Trigger Notas.)
DELIMITER //
CREATE TRIGGER Notas
AFTER UPDATE ON JogadoresEstatísticasPorJogo
FOR EACH ROW
begin
set @Nome = new.Nome;
set @GolsPJN = new.GolsPJ;
set @AstPJN = new.AssistsPJ;
set @PreAstPJN = new.PréAstPJ;
set @GrandesChancesCriadasPJN = new.GrandesChancesCriadasPJ;
set @GrandesChancesErradasPJN = new.GrandesChancesErradasPJ;
set @PassesTentadosPJN = new.PassesTentadosPJ;
set @PassesCompletosPJN = new.PassesCompletosPJ;
set @PorcentagemPassesPJN = new.PorcentagemPassesPJ;
set @DriblesTentadosPJN = new.DriblesTentadosPJ;
set @DriblesCompletosPJN = new.DriblesCompletosPJ;
set @ChutesTentadosPJN = new.ChutesTentadosPJ;
set @ChutesNoGolPJN = new.ChutesNoGolPJ;
set @ChutesBloqueadosPJN = new.ChutesBloqueadosPJ;
set @PerdadePossePJN = new.PerdadePossePJ;
set @DesarmesCompletosPJN = new.DesarmesCompletosPJ;
set @TentativasSofridasdeDriblePJN = new.TentativasSofridasdeDriblePJ;
set @DriblesSofridosPJN = new.DriblesSofridosPJ;
set @BloqueiosPJN = new.BloqueiosPJ;
set @InterceptacoesPJN = new.InterceptaçõesPJ;
set @DuelosAereosGanhosPJN = new.DuelosAéreosGanhosPJ;
set @DuelosAereosPerdidosPJN = new.DuelosAéreosPerdidosPJ;
set @FaltasCometidasPJN = new.FaltasCometidasPJ;
set @GolsNotas = @GolsPJN * 25;
set @GrandesChancesErradasNotas = (@GolsPJN - @GrandesChancesErradasPJN) * 17;
set @DriblesNotas = @DriblesCompletosPJN / @DriblesTentadosPJN * 2;
set @ChutesNotas = @ChutesnoGolPJN / @ChutesTentadosPJN * 15;
set @PerdadePosseNotas = @PerdadePossePJN / (@PassesTentadosPJN + @DriblesTentadosPJN) * (-65);
set @AstNotas = @AstPJN * 25;
set @PreAst = @PreAstPJN * 50;
set @GrandesChancesCriadas = @GrandesChancesCriadasPJN / @PassesCompletosPJN * 60;
set @PorcentagemNotas = @PorcentagemPassesPJN / 10 * 1.50;
set @DesarmesNotas = @DesarmesCompletosPJN * 25;
set @DriblesSofridosNotas = (10 - (@DriblesSofridosPJN / @TentativasSofridasdeDriblePJN * 3,5)) *2;
set @FaltasCometidasNotas = @FaltasCometidasPJN * (-8);
set @BloqueiosInterceptacoesNotas = (@BloqueiosPJN * 2 + @InterceptacoesPJN * 7) *3;
set @NotaOfensiva = truncate ((@GolsNotas + @GrandesChancesErradasNotas + DriblesNotas + ChutesNotas + PerdadePosseNotas) / 10 , 2);
set @NotaCriacao = truncate ((@AstNotas + @PreAst + @GrandesChancesCriadas + @PorcentagemNotas) / 10, 2);
set @NotaDefensiva = truncate ((@DesarmesNotas + @DriblesSofridosNotas + @FaltasCometidasNotas + @BloqueiosInterceptacoesNotas) / 10 , 2);
set @NotaGeral = (@NotaOfensiva + @NotaCriacao + @NotaDefensiva) / 3;
update JogadoresNotas set NotaOfensiva = @NotaOfensiva where Nome = @Nome;
update JogadoresNotas set NotaCriação = @NotaCriacao where Nome = @Nome;
update JogadoresNotas set NotaDefensiva = @NotaDefensiva where Nome = @Nome;
update JogadoresNotas set NotaGeral = @NotaGeral where Nome = @Nome;
end //
DELIMITER ;
My Updates:
DELIMITER // begin
Update JogadoresEstatísticasBrutas SET Nome = 'R', Jogos = "7", Gols = "3", Assists = "5", PréAst = "0", GrandesChancesCriadas = "10", GrandesChancesErradas = "4", PassesTentados = "65", PassesCompletos = "55", PorcentagemPasses = "84", DriblesTentados = "18", DriblesCompletos = "11", ChutesTentados = "7", ChutesNoGol = "5", ChutesBloqueados = "1", PerdadePosse = "13", DesarmesCompletos = "6", TentativasSofridasdeDrible = "8", DriblesSofridos = "4", Bloqueios = "10", Interceptações = "4", DuelosAéreosGanhos = "1", DuelosAéreosPerdidos = "0", FaltasCometidas = "2", FaltasSofridas = "2", ChutesSofridos = "6", Defesas = "3", ChutesDifíceis = "3", DefesasDifíceis = "0" where Nome = "R";
Update JogadoresEstatísticasBrutas SET Nome = 'N', Jogos = "7", Gols = "3", Assists = "2", PréAst = "1", GrandesChancesCriadas = "5", GrandesChancesErradas = "4", PassesTentados = "37", PassesCompletos = "29", PorcentagemPasses = "78", DriblesTentados = "12", DriblesCompletos = "6", ChutesTentados = "10", ChutesNoGol = "5", ChutesBloqueados = "0", PerdadePosse = "8", DesarmesCompletos = "3", TentativasSofridasdeDrible = "11", DriblesSofridos = "7", Bloqueios = "3", Interceptações = "0", DuelosAéreosGanhos = "1", DuelosAéreosPerdidos = "0", FaltasCometidas = "4", FaltasSofridas = "2", ChutesSofridos = "9", Defesas = "7", ChutesDifíceis = "2", DefesasDifíceis = "1" where Nome = "N";
Update JogadoresEstatísticasBrutas SET Nome = 'B', Jogos = "7", Gols = "6", Assists = "3", PréAst = "1", GrandesChancesCriadas = "4", GrandesChancesErradas = "6", PassesTentados = "54", PassesCompletos = "48", PorcentagemPasses = "88", DriblesTentados = "22", DriblesCompletos = "14", ChutesTentados = "25", ChutesNoGol = "10", ChutesBloqueados = "7", PerdadePosse = "14", DesarmesCompletos = "7", TentativasSofridasdeDrible = "10", DriblesSofridos = "6", Bloqueios = "4", Interceptações = "5", DuelosAéreosGanhos = "0", DuelosAéreosPerdidos = "3", FaltasCometidas = "4", FaltasSofridas = "4", ChutesSofridos = "7", Defesas = "4", ChutesDifíceis = "5", DefesasDifíceis = "2" where Nome = "B";
Update JogadoresEstatísticasBrutas SET Nome = 'F', Jogos = "7", Gols = "8", Assists = "1", PréAst = "1", GrandesChancesCriadas = "6", GrandesChancesErradas = "3", PassesTentados = "55", PassesCompletos = "40", PorcentagemPasses = "72", DriblesTentados = "18", DriblesCompletos = "10", ChutesTentados = "17", ChutesNoGol = "7", ChutesBloqueados = "4", PerdadePosse = "10", DesarmesCompletos = "9", TentativasSofridasdeDrible = "19", DriblesSofridos = "7", Bloqueios = "14", Interceptações = "3", DuelosAéreosGanhos = "0", DuelosAéreosPerdidos = "0", FaltasCometidas = "2", FaltasSofridas = "3", ChutesSofridos = "13", Defesas = "9", ChutesDifíceis = "7", DefesasDifíceis = "3" where Nome = "F";
Update JogadoresEstatísticasBrutas SET Nome = 'G', Jogos = "7", Gols = "9", Assists = "1", PréAst = "1", GrandesChancesCriadas = "6", GrandesChancesErradas = "5", PassesTentados = "52", PassesCompletos = "44", PorcentagemPasses = "84", DriblesTentados = "8", DriblesCompletos = "1", ChutesTentados = "29", ChutesNoGol = "21", ChutesBloqueados = "6", PerdadePosse = "11", DesarmesCompletos = "5", TentativasSofridasdeDrible = "15", DriblesSofridos = "9", Bloqueios = "9", Interceptações = "5", DuelosAéreosGanhos = "1", DuelosAéreosPerdidos = "0", FaltasCometidas = "0", FaltasSofridas = "2", ChutesSofridos = "5", Defesas = "2", ChutesDifíceis = "3", DefesasDifíceis = "1" where Nome = "G";
Update JogadoresEstatísticasBrutas SET Nome = 'D', Jogos = "7", Gols = "4", Assists = "0", PréAst = "1", GrandesChancesCriadas = "6", GrandesChancesErradas = "7", PassesTentados = "55", PassesCompletos = "51", PorcentagemPasses = "92", DriblesTentados = "12", DriblesCompletos = "6", ChutesTentados = "19", ChutesNoGol = "13", ChutesBloqueados = "4", PerdadePosse = "10", DesarmesCompletos = "9", TentativasSofridasdeDrible = "22", DriblesSofridos = "12", Bloqueios = "8", Interceptações = "1", DuelosAéreosGanhos = "0", DuelosAéreosPerdidos = "0", FaltasCometidas = "3", FaltasSofridas = "0", ChutesSofridos = "3", Defesas = "1", ChutesDifíceis = "2", DefesasDifíceis = "1" where Nome = "D";
end; DELIMITER;
Tables JogadoresEstatísticasBrutas and JogadoresNotas
CREATE TABLE IF NOT EXISTS JogadoresEstatísticasBrutas (
IdJogadores INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Nome VARCHAR(40) NULL,
Jogos INT NULL,
Gols INT NULL,
Assists INT NULL,
PréAst INT NULL,
GrandesChancesCriadas INT NULL,
GrandesChancesErradas INT NULL,
PassesTentados INT NULL,
PassesCompletos INT NULL,
PorcentagemPasses INT NULL,
DriblesTentados INT NULL,
DriblesCompletos INT NULL,
ChutesTentados INT NULL,
ChutesNoGol INT NULL,
ChutesBloqueados INT NULL,
PerdadePosse INT NULL,
DesarmesCompletos INT NULL,
TentativasSofridasdeDrible INT NULL,
DriblesSofridos INT NULL,
Bloqueios INT NULL,
Interceptações INT NULL,
DuelosAéreosGanhos INT NULL,
DuelosAéreosPerdidos INT NULL,
FaltasCometidas INT NULL,
FaltasSofridas INT NULL,
ChutesSofridos INT NULL,
Defesas INT NULL,
ChutesDifíceis INT NULL,
DefesasDifíceis INT NULL);
CREATE TABLE IF NOT EXISTS JogadoresNotas (
IdJogadores INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
Nome VARCHAR(40) NULL,
Jogos INT NULL,
NotaOfensiva FLOAT (3, 2) NULL,
NotaCriação FLOAT (3, 2) NULL,
NotaDefesinva FLOAT (3, 2) NULL,
NotaGeral FLOAT (4, 2) NULL);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 参考手册,您可以使用
set
更改以,
分隔的多个值。Per reference manual, you can use
set
to change multiple values that are,
separated.