2

I'm trying to create a procedure but it gives me syntax error. I am not certain of what seems to be the problem

        delimiter $$
        create
        procedure inactivity()
        LANGUAGE SQL
        begin
        [mysql block]
        end $$
        delimiter; 
3
  • What is the error message and which line does it relate to? Commented May 14, 2013 at 18:02
  • @w5m, 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 'create procedure question_inactivity() begin delete from questions_temp where ' at line 2 Commented May 14, 2013 at 18:05
  • TIP: write each SQL statement properly, end line with ; wherever necessary , inside the [ mysql block ] Commented May 15, 2013 at 5:12

2 Answers 2

4

Try this sql code:

delimiter $$
drop procedure if exists question_inactivity;
create procedure question_inactivity()
begin
delete from questions_temp where active= 1;
update questions set active = 0 where question_id in(select question_id from questions_temp);
drop table questions_temp;
end $$
delimiter;

------------------------------UPDATE------------------------------------

I running this in phpmyadmin and it'works:

delimiter $$

create procedure question_inactivity()
begin
delete from questions_temp where active= 1;
update questions set active = 0 where question_id in(select question_id from questions_temp);
drop table questions_temp;
end 

$$

In the Delimiter input field i put this value: $$

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

Comments

4

I figured it out by myself. What was wrong is that there was no space between delimiter and the semicolon.

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.