我有點小白,當談到一般的存儲過程,但我想寫以下不能創建MySQL存儲過程
Create procedure clone_perms
as
declare @new_id varchar(30), @old_id varchar(30)
declare get_perms cursor for select userspermsUserid, userspermsPermission from users_permissions where [email protected]_id
declare @perms varchar(30), @on_off boolean
FETCH get_perms into @perms, @on_off
while(@@sqlstatus=0)
BEGIN
if exists (select 1 from permissions where [email protected]_id and [email protected])
BEGIN
update permissions set [email protected]_off where [email protected]_id and [email protected]
END
else
BEGIN
insert permissions (userspermsUserID, userspermsPermID, userspermsPermission) values (@new_id, @perms, @on_off)
END
FETCH get_perms into @perms, @on_off
END
CLOSE get_perms
DEALLOCATE CURSOR get_perms
end
。嘗試創建時出現以下錯誤:
/* SQL錯誤(1064):您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以便在第二行使用'as declare @new_id varchar(30)declare @old_id varchar(30)declare get_perm'使用正確的語法*/
。有誰知道我需要做什麼來完成這項工作?
請在您的問題中包含服務器版本 – 2011-02-04 14:29:05
我正在使用5.1.45社區 – Jonathan 2011-02-04 14:40:09