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$$
4
  • Works for me. How do you execute it Commented Aug 15, 2014 at 10:50
  • I have executed in phpMyAdmin Commented Aug 15, 2014 at 10:51
  • Strange. Do you have code before that function when you execute? Remove it if so and execute this code only. Commented Aug 15, 2014 at 10:53
  • No. There is no more code/command. Commented Aug 15, 2014 at 11:00

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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 ;

1 Comment

As per 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.