Matt W
Matt W

Reputation: 12423

Can't create basic stored proc on MariaDB

The documented stored procedure on the MariaDB page fails to execute for me:

https://mariadb.com/kb/en/mariadb/documentation/sql-commands/data-definition/create/create-procedure/

DELIMITER //

CREATE PROCEDURE simpleproc (OUT param1 INT)
 BEGIN
  SELECT COUNT(*) INTO param1 FROM t;
 END;
//

I get this error:

The following errors were reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER // CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN SELECT COUNT' at line 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '//' at line 1

What am I doing wrong and how can I fix it?

Upvotes: 4

Views: 4479

Answers (1)

batressc
batressc

Reputation: 1588

Adds the following statement to the end of the script: DELIMITER ;

DELIMITER //

CREATE PROCEDURE simpleproc (OUT param1 INT) BEGIN
    SELECT COUNT(*) INTO param1 FROM t;
END;
//
DELIMITER ;

Upvotes: 8

Related Questions