0

New to SQL and trying to run this code and I get the error "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@Qtable TABLE(Qid INT) END' at line 3". The code runs fine if I take out the DECLARE statement;

SET @query_id = (SELECT ID from ua820988_dev.users WHERE `email` = 'example@gmail.com');
CREATE PROCEDURE query_requests()
BEGIN
    DECLARE @Qtable TABLE(Qid INT)
END;
SELECT * from ua820988_dev.requests WHERE `match` = @query_id;
SELECT * from ua820988_dev.requests_archive WHERE `match` = @query_id;

I'm hoping to eventually put the results from the 2nd and 3rd SELECT statements into the table, but this is the watered down version for now just trying to get the code to run. I'm running SQL 5.6 on MariaDB 10.2.

  • First, time to upgrade! (see note under "February 1, 2021" on https://www.mysql.com/support/eol-notice.html ), but I notice that for 10.2 you have until 23 May 2022 (https://endoflife.date/mariadb) Please delete the tag `mysql5.6` or the tag `mariadb-10.2`, and only keep the tag for the database that you are using!) – Luuk Mar 06 '21 at 19:54
  • Why do you want to DECLARE a variable that you do not use? It is not in use in the code you provided so far , an creating a procedure which only declares a variable is (at least a but, strange. – Luuk Mar 06 '21 at 19:55
  • @Luuk, I'll eventually use the variable, I just want it to get past this point before I start writing the code to use it. – Kristi Perkins Mar 06 '21 at 20:07
  • 1
    Are you sure MariaDb even supports this? https://stackoverflow.com/q/58279983/73226 – Martin Smith Mar 06 '21 at 20:17
  • 1
    I do not see `TABLE` between the datatypes (see: https://mariadb.com/kb/en/data-types/) and `ROW` is there but it is supported from version 10.3+ – Luuk Mar 06 '21 at 20:21
  • Thanks, MartinSmith and Luuk, that would be the problem! – Kristi Perkins Mar 06 '21 at 21:33

0 Answers0