0

I want to crate a very basic routine in my mqsql mariadb that inserts data into a table.

While testing in the SQL Editor, everything works fine:

SELECT @userid:=rowid from userdata where username like 'testuser';

SELECT @now:=NOW();

INSERT INTO tracks(userid, trackname, link, timestamp) VALUES (@userid, 'test', 'test', @now);

But when I want to paste this code into a routine I get the error:

MySQL said: #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 'SELECT @now:=NOW(); INSERT INTO tracks(userid, trackname, link, timestamp) VA' at line 3

I selected the SecurityType "DEFINER" and SQL data access to "NO SQL" or to "MODIFIES SQL DATA".

Any Ideas?

EDIT1:enter image description here

yesfabime
  • 814
  • 1
  • 12
  • 27
  • routine? where? if that's in some code somewhere, probably the underlying mysql driver doesn't allow multiple statements in a single `query()` call, meaning you have to send each statement over in a SEPARATE query call: `query('select @userid...'); query('select @now ...'); query('insert ...');` – Marc B Nov 02 '16 at 15:21
  • In phpmyadmin it's called routine or procedure. Like the equivalent in mssql called stored procedure. So there isn't a way to do more than one query in one procedure call? – yesfabime Nov 02 '16 at 15:46
  • then show the entire procedure definition. possibly you forgot to change the delimiter, meaning the first `;` terminates the procedure definition itself, not just the one line inside the procedure. – Marc B Nov 02 '16 at 16:54

0 Answers0