1

i have the following syntax for creating a stored procedure in MySQL 5.0.10

delimiter //
CREATE PROCEDURE getTweets (var1 varchar(100))
LANGUAGE SQL
SQL SECURITY DEFINER
COMMENT 'A procedure to return 20 least scored tweets based on the temp sessionid of the user'
BEGIN
    SELECT count(ts.tweetid) as "count",t.id as "tweetid", t.tweettext as "tweet"
    FROM tweets t
    LEFT JOIN tweetscores ts ON t.id = ts.tweetid
    where t.id not in (select distinct(tweetid) from tweetscores where  temp_sessionid=var1)
    group by t.id, t.tweettext order by count   
    LIMIT 10;
END//

i keep on getting 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 '//' at line 12

can anybody spot the error..

9
  • Works for me. How do you execute it? Commented Jan 21, 2015 at 8:39
  • Try keeping the delimiter in next line Commented Jan 21, 2015 at 8:39
  • @juergend just clicked on the go button in phpmyadmin... Commented Jan 21, 2015 at 8:52
  • @Sai done that but no effect... Commented Jan 21, 2015 at 8:53
  • @dakait: Remove the delimiter // part. In PHPMyAdmin you dont need it I think. Commented Jan 21, 2015 at 8:53

2 Answers 2

3

Your query works when executing it as a script on DB level.

But using PhpMyAdmin you need remove the delimiter statement.

CREATE PROCEDURE getTweets (var1 varchar(100))
LANGUAGE SQL
SQL SECURITY DEFINER
COMMENT 'A procedure to return 20 least scored tweets based on the temp sessionid of the user'
BEGIN
    SELECT count(ts.tweetid) as "count",t.id as "tweetid", t.tweettext as "tweet"
    FROM tweets t
    LEFT JOIN tweetscores ts ON t.id = ts.tweetid
    where t.id not in (select distinct(tweetid) from tweetscores where  temp_sessionid=var1)
    group by t.id, t.tweettext order by count   
    LIMIT 10;
end

PhpMyAdmin will do the rest for you.

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

Comments

0
CREATE PROCEDURE getTweets (var1 varchar(100))
LANGUAGE SQL
SQL SECURITY DEFINER
COMMENT 'A procedure to return 20 least scored tweets based on the temp sessionid of the user'
BEGIN
    SELECT count(ts.tweetid) as "count",t.id as "tweetid", t.tweettext as "tweet"
    FROM tweets t
    LEFT JOIN tweetscores ts ON t.id = ts.tweetid
    where t.id not in (select distinct(tweetid) from tweetscores where  temp_sessionid=var1)
    group by t.id, t.tweettext order by count   
    LIMIT 10;
end

Comments

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.