2013-05-14 187 views
0

我试图创建一个过程,但它给了我语法错误。我不能肯定什么似乎是问题MySQL存储过程不带参数

 delimiter $$ 
     create 
     procedure inactivity() 
     LANGUAGE SQL 
     begin 
     [mysql block] 
     end $$ 
     delimiter; 
+0

什么是错误消息和线?它与? – w5m 2013-05-14 18:02:03

+0

@ w5m,这是错误:#1064 - 你的SQL语法有错误;检查对应于你的MySQL服务器版本使用附近的正确语法手册“CREATE PROCEDURE question_inactivity() 开始 从questions_temp其中删除”在第2行 – Wabbit 2013-05-14 18:05:40

+0

提示:写正确每个SQL语句,与'端线;'哪里需要在[mysql block]里面 – diEcho 2013-05-15 05:12:31

回答

2

我想通了我自己。有什么问题是分隔符和分号之间没有空格。

1

试试这个SQL代码:

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

我在phpMyAdmin和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 

$$ 

在分隔符输入字段我把这个值:$$

+0

它给了我相同的语法错误(错误#1064) – Wabbit 2013-05-14 18:09:05

+0

我更新了答案 – Hackerman 2013-05-14 19:15:02