"Syntax error: Missing 'semicolon'" in Mysql database

Asked

Viewed 1,170 times

2

I have the procedure down below

CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_notasAluno`(IN aluno INT)
BEGIN 
  DECLARE ditCodigo,courseId INT;
  DECLARE usuario VARCHAR(50);
  DECLARE notafinaloff,notafinalon,somanotaon float;

  select gg.id, SUM(finalgrade) AS notaFinal,SUM(grademax) as NotaMaxima from mdl_grade_grades gg
  INNER JOIN mdl_grade_items gi on gg.itemid = gi.id
  INNER JOIN mdl_course course ON gi.courseid = course.id
  INNER JOIN mdl_user user ON gg.userid = user.id
  where userid = aluno AND itemmodule like 'assign' GROUP BY itemmodule;

  select @ditCodigo=course.idnumber,@usuario=username,@courseId=course.id,SUM(finalgrade) AS notaFinal from mdl_grade_grades gg
  INNER JOIN mdl_grade_items gi on gg.itemid = gi.id
  INNER JOIN mdl_course course ON gi.courseid = course.id
  INNER JOIN mdl_user user ON gg.userid = user.id
  where userid = aluno AND itemmodule like 'quiz' GROUP BY itemmodule;

  CREATE TEMPORARY TABLE notas (dit_codigo int,login varchar(50),cur_codigo int,notaOn decimal,notaOff decimal,idNota int, notaOffMax decimal) VALUES ()
END

When executing the following error occurs in the creation of the time table:

Syntax error: missing 'semicolon'
  • Create temporary table with VALUES ()?

  • I will add some parameters that I recover from a select...

1 answer

4


CREATE TEMPORARY TABLE notas (dit_codigo int,[login] varchar(50),cur_codigo int,notaOn decimal,notaOff decimal,idNota int, notaOffMax decimal) VALUES ()
END

login is a reserved word. Add keys to it.

  • How to save a select values in variables?

  • CREATE TEMPORARY TABLE notas (dit_codigo int,[login] varchar(50),cur_codigo int,notaOn decimal,notaOff decimal,idNota int, notaOffMax decimal) select coluna_1, coluna_2, coluna_3, coluna_4, coluna_5, coluna_6, coluna_7 from tabela

Browser other questions tagged

You are not signed in. Login or sign up in order to post.