How do I create a stored procedure in heidisql?

HanTael picture HanTael · Jun 15, 2016 · Viewed 9.2k times · Source

I'm trying to create a stored procedure in heidisql (mysql).

CREATE PROCEDURE SP_FORM20_POST(
    P_SESSIONID     VARCHAR(256)
)
BEGIN
    INSERT INTO tbForm20
        ( SESSIONID, RegDT)
    VALUES
        ( P_SESSIONID, NOW()); 
END

This is my query. I'm trying to create this procedure, but occur some error:

Error code is 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'' at line 8".

However, I don't know wrong syntax. What is wrong?

I want to success in heidisql tool. I don't want other db tool. Please help me.

Answer

Anse picture Anse · Sep 15, 2016

The problem in that query is the semicolon, which is the default query delimiter.

In order to change the delimiter in HeidiSQL, add the DELIMITER client command above the CREATE PROCEDURE query:

DELIMITER \\
SELECT 1\\
CREATE PROCEDURE ...\\
DELIMITER ;

HeidiSQL also has a procedure designer, with no need to set the delimiter:

HeidiSQL procedure designer