How do I create a stored procedure in heidisql?
Solution 1
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:
Solution 2
The problem is this. The database reads the ;
in your code as an end of the procedure. You probably don't intend it like that :). The DELIMITER
command takes care of that by changing ;
to something customizable, like $$
. Try this:
DELIMITER $$
CREATE PROCEDURE SP_FORM20_POST(
P_SESSIONID VARCHAR(256)
)
BEGIN
INSERT INTO tbForm20
( SESSIONID, RegDT)
VALUES
( P_SESSIONID, NOW());
END$$
DELIMITER ;
HanTael
Updated on June 16, 2022Comments
-
HanTael almost 2 years
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.