php - Syntax error in mySql to create Procedures
Get the solution ↓↓↓DELIMITER $$
DROP PROCEDURE IF EXISTS `unitstoamount`;
CREATE DEFINER=`root`@`localhost` PROCEDURE `unitstoamount`( IN units INT(14) , OUT result INT(14))
BEGIN
DECLARE a INT(14) DEFAULT 0;
DECLARE b INT(14) DEFAULT 0;
DECLARE c INT(14) DEFAULT 0;
SELECT twohundred FROM unitsRate INTO a ;
SELECT fivehundred FROM unitsRate INTO b ;
SELECT thousand FROM unitsRate INTO c ;
IF units<200
then
SELECT a*units INTO result;
ELSEIF units<500
then
SELECT (a*200)+(b*(units-200)) INTO result;
ELSEIF units > 500
then
SELECT (a*200)+(b*(300))+(c*(units-500)) INTO result;
END IF;
END$$
DELIMITER ;
Answer
Solution:
You have set the DELIMITER to be$$
. So, you should use it also in theDROP PROCEDURE
statement:
DELIMITER $$
DROP PROCEDURE IF EXISTS `unitstoamount`
$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `unitstoamount`( IN units INT(14) , OUT result INT(14))
...
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function update() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.