0

I am trying to create a function that returns rowcount. But it returns error again and again.

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 11

DELIMITER $$
CREATE FUNCTION func1(userid INT)
RETURNS INT
NOT DETERMINISTIC
BEGIN
  DECLARE var_name INT;
  SET var_name = 0;
  SELECT COUNT(*) INTO var_name
    FROM wps_bal
    WHERE u_id = userid;
  RETURN var_name;
END$$
Community
  • 1
  • 1
user174372
  • 17
  • 5

2 Answers2

1

Most probably your version of PHPMyAdmin does not support the DELIMITER statement which is not MySQL statement. Here you can find how to create the function in PHPMyAdmin: Store procedures in phpMyAdmin

Community
  • 1
  • 1
0

Yes. This was helpfull

I have created the solution:

DELIMITER $$
CREATE FUNCTION func1(userid INT)
RETURNS INT
NOT DETERMINISTIC
BEGIN
  DECLARE var_name INT;
  SET var_name = 0;
  SELECT COUNT(*) INTO var_name
    FROM wps_bal
    WHERE u_id = userid;
  RETURN var_name;
END$$
DELIMITER ;
Community
  • 1
  • 1
user174372
  • 17
  • 5
  • As per https://stackoverflow.com/help/self-answer, you can accept your own Answer after 48 hours. This will have the effect of removing your Question from the list of unanswered Questions. – toonice Apr 28 '17 at 16:27