I'm trying to create a stored procedure in MariaDB using the code below.
DELIMITER //
CREATE PROCEDURE P5();
BEGIN
IF 1=1 THEN
SELECT 1;
END IF;
END//
When I run the code, I receive a syntax 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 ';
BEGIN
IF 1=1 THEN
SELECT 1;
END IF;
END' at line 1
I realise that I could use an IF ()
function in this case, but I need to be able to use IF
statements.
CodePudding user response:
No need of adding semicolon after procedure name.
DELIMITER //
CREATE PROCEDURE P5()
BEGIN
IF 1=1 THEN
SELECT 1;
END IF;
END//
Check db fiddle
Refer: MySQL Docs