I'm creating a stored procedure on localhost PHPmyAdmin, but there is an error I cannot find

Viewed 42

I have written this code but its shows error at the line 10. in my Editor line 10 is INSERT INTO employee(Name,EmpCode,Salary). Below is my code

CREATE PROCEDURE `EmployeeAddOrEdit`(
    IN _EmpID INT,
    IN _Name varchar(45),
    IN _EmpCode varchar(45),
    IN _Salary int
)
BEGIN 
IF _EmpID=0 THEN
    INSERT INTO employee(Name,EmpCode,Salary)
    VALUES (_Name,_EmpCode,_Salary);
    SET   _EmpID=LAST_INSERT_ID();
ELSE
    UPDATE employee
    SET 
    Name=_Name,
    EmpCode=_EmpCode,
    Salary=_Salary
    WHERE EmpID=_EmpID;
END IF;
SELECT _EmpID AS 'EmpID';
END 

This is the 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 '' at line 10

1 Answers

In PHPMyAdmin SQL section,

set the Delimiter to $$ instead of ;

and then run the query again.
See picture for reference Reference Picture

Related