I cant figure out what is the problem below:
CREATE DEFINER=`root`#`localhost` PROCEDURE `test0`(
$qsFilter VARCHAR(50)
)
BEGIN
SELECT
cs.Customer_First_Name
FROM customer_subscriptions cs
WHERE 1=1 AND ($qsFilter IS NULL OR cs.Customer_First_Name = $qsFilter)
END$$
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END'
I think you just need a semicolon, but I would write this as:
DELIMITER $$
CREATE DEFINER=`root`#`localhost` PROCEDURE `test0`(
in_qsFilter VARCHAR(50)
)
BEGIN
SELECT cs.Customer_First_Name
FROM customer_subscriptions cs
WHERE 1 = 1 AND
(in_qsFilter IS NULL OR cs.Customer_First_Name = in_qsFilter);
END$$
Related
I'm trying to create a function, but keep getting the error message that
SQL 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 3.
DELIMITER $$
DROP FUNCTION IF EXISTS mysql.HelpMePlz$$
CREATE FUNCTION mysql.HelpMePlz(input VARCHAR(255) ) RETURNS VARCHAR(255) BEGIN
DECLARE result VARCHAR(255);
SELECT name into result
FROM tb_company
WHERE company_info = input
LIMIT 3
RETURN result;
END $$
DELIMITER ;
I have create this function
DELIMITER $$
CREATE FUNCTION func05(x1 int)
RETURNS varchar(100) CHARSET utf8
READS SQL DATA
BEGIN
RETURN (SELECT txt FROM strutture INNER JOIN dizionario ON dz_nome = idtxt WHERE idls = x1 LIMIT 0,1)
END$$
DELIMITER ;
But returns this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'END' at line 6
I have a simple stored procedure:
DELIMITER $$
CREATE PROCEDURE `my_proc`(IN mac VARCHAR(12), IN my_field1 INTEGER)
BEGIN
UPDATE mytable SET field1 = my_field1 WHERE mac_address = mac;
END$$
This gives me:
1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '' at line 4
Line 4 is "BEGIN"
How is that possible?
simple question
this is the code to creat a simple stored procedure
DELIMITER $$
CREATE PROCEDURE `check_mobile_sp`(
IN mobile_numberEntered VARCHAR(12)
)
BEGIN
SELECT id, mobile_number, `date`
from users
WHERE mobile_number = mobile_numberEntered;
END $$
DELIMITER ;
and this is the error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1
try placing // instead of $$:
DELIMITER //
CREATE PROCEDURE `check_mobile_sp`(
IN mobile_numberEntered VARCHAR(12)
)
BEGIN
SELECT id, mobile_number, `date`
from users
WHERE mobile_number = mobile_numberEntered;
END //
DELIMITER ;
I keep getting the following error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''v_id' varchar(20) null , OUT 'v_status' varchar(40)) IS Begin ' at line 2
It is the first time I'm using MySql and the little pl sql knowledge isn't really helping.
delimiter //
->CREATE PROCEDURE dbi292801.campsite
(IN 'v_id' varchar(20) null ,
OUT 'v_status' varchar(40)) IS
Begin
SELECT status into v_status FROM participant WHERE RFID = v_id;
if (v_status = "in", v_status := "at campsite", v_status := 'at event');
End if;
End //
If you have an idea to solve this, please reply!!