我試圖創建一個存儲過程,無論是在命令行或MySQL Workbench中編輯器。MySQL的:創建過程錯誤
在Mysql WOrkbench中我根本沒有任何信息,沒有成功沒有錯誤,但程序沒有創建。在命令行mysql --host=localhost ... < procedure-script.sql
我得到以下錯誤:
ERROR 1064 (42000) at line 4: 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 'DELIMITER' at line 28
線28實際上是空的,但是我想它是指最終DELIMITER ;
在第31行下面是完整的代碼:
DELIMITER $$;
-- drop procedure if exists updPages$$
CREATE PROCEDURE updPages()
BEGIN
DECLARE _post_id INTEGER;
DECLARE cur_pages CURSOR FOR
select ID
from wp_posts
where post_type='page' and ID not in (select post_id from wp_postmeta);
OPEN cur_pages;
Reading_Pages: LOOP
FETCH cur_pages INTO _post_id;
IF done THEN
LEAVE Reading_Pages;
END IF;
insert into wp_postmeta(post_id, meta_key, meta_value)
values (_post_id, '_wp_page_template', 'default'),
(_post_id, 'upside-show-page-title', '1'),
(_post_id, 'upside-show-breadcrumb', '1'),
(_post_id, 'upside-page-show-document-search', '0'),
(_post_id, 'upside-show-page-title-middle', 'false'),
(_post_id, '_vc_post_settings', 'a:1:{s:10:"vc_grid_id";a:0:{}}');
END LOOP;
CLOSE cur_pages;
END$$
DELIMITER ;
(1 )有沒有錯誤? (2)你知道如何在Mysql Workbench中顯示編譯錯誤嗎? (3)從命令行運行它們時,我可以使用tab內部的腳本嗎? (我不得不剝離出來作爲我有錯誤)
刪除分號嘗試此; – rocks