in Education by
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); JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Per reference manual, you can use set to change multiple values that are , separated. CREATE TRIGGER Notas AFTER UPDATE ON JogadoresEstatísticasPorJogo FOR EACH ROW set @Nome = new.Nome, @GolsPJN = new.GolsPJ, @AstPJN = new.AssistsPJ, ....

Related questions

0 votes
    SELECT id, amount FROM report I need amount to be amount if report.type='P' and -amount if report.type='N' ... this to the above query? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I've come to this code, but from this i have to manually insert all columns and check it by each ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    How to set same number 'priority' with one query for Mercedes. +--------------------- ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    The text data I have for a column in database in an enterprise application (uses hibernate) is huge and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    The text data I have for a column in database in an enterprise application (uses hibernate) is huge and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    The text data I have for a column in database in an enterprise application (uses hibernate) is huge and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    I'm attempting to copy my MySQL database from an Amazon EC2 to an RDS: I successfully did a mysqldump of ... easy question. Thoughts? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I am using a pre-trained doc2vec model, when I try to find out most similar document to that of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm trying to install MySQL for Visual Studio 1.2.8 and Connector/NET 8.0.13 via MySQL Installer ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    How to enable inno-db support on installed instance of MySql? I have installed mysql-5.0.67-win32. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I want to connect to db on EC2 from my local machine, I am not able to do and have tried everything- I ... to connect to the database Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have a big table which contains about 100 million records in MySQL. I want to read all the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    Why does this mysql query fail? UPDATE accounts SET motivation = IF(motivation+100...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I'm trying to set the ideal performance setup for MySQL and resources needed on a shared hosting. My ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I already can update my data from database but the problem is i just want to update one data, but when I enter the ... all of data in the database table like this this is View:...
asked Jun 2, 2022 in Education by JackTerrance
...