簡體   English   中英

錯誤代碼:1241。操作數應包含 1 列關於更新和觸發器

[英]Error Code: 1241. Operand should contain 1 column(s) On Updates and Trigger

我有一個足球數據庫,我有一個觸發器(notas),它在插入他的統計數據后計算球員評分,我能夠創建觸發器,但是當我更新球員統計數據時,它給我錯誤代碼:1241

(我的更新在 Table JogadoresEstatísticasBrutas 中,但因為有其他觸發器在工作,並且該觸發器在 Table JogadoresEstatísticasPorJogo 上插入統計信息,經過一些測試后我發現問題出在 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 ;

我的更新:

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);

根據參考手冊,您可以使用set更改多個分隔的值。

CREATE TRIGGER Notas 
AFTER UPDATE ON JogadoresEstatísticasPorJogo 
FOR EACH ROW
set @Nome = new.Nome,
    @GolsPJN = new.GolsPJ,
    @AstPJN = new.AssistsPJ,
    ....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM