user174372
user174372

Reputation: 17

MySQL Create function returns error

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$$

Upvotes: 0

Views: 136

Answers (2)

user174372
user174372

Reputation: 17

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 ;

Upvotes: 0

user3863110
user3863110

Reputation:

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

Upvotes: 1

Related Questions