我创建了一个时间维度表,我正在尝试填充它,但它给出了错误。我无法解决它。
“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便在”CREATE PROCEDURE timedimbuild()附近使用正确的语法“
delimiter //
DROP PROCEDURE IF EXISTS timedimbuild;
CREATE PROCEDURE timedimbuild ()
BEGIN
DECLARE v_full_date DATETIME;
DELETE FROM timedim;
SET v_full_date = '2009-03-01 00:00:00';
WHILE v_full_date < '2009-03-02 00:00:00' DO
INSERT INTO timedim (
fulltime ,
hour ,
minute ,
second ,
ampm
) VALUES (
TIME(v_full_date),
HOUR(v_full_date),
MINUTE(v_full_date),
SECOND(v_full_date),
DATE_FORMAT(v_full_date,'%p')
);
SET v_full_date2 = DATE_ADD(v_full_date2, INTERVAL 1 SECOND);
END WHILE;
END;
//
delimiter ;
答案 0 :(得分:0)
如果更改分隔符
delimiter //
然后你必须使用新的。因此,而不是;
使用//
DROP PROCEDURE IF EXISTS timedimbuild//