SELECT
ss, s1, S3, dd, dde, edsd, sd3, rff, reee, dd333
FROM mytable
WHERE 1=1
drop procedure if Exists prc_mytable_INIT;
CREATE PROCEDURE prc_mytable_INIT(nCount INT)
BEGIN
DECLARE I INT default 0;
WHILE I < nCount DO
SET I = I+1;
INSERT INTO mytable (ss, s1, dde)
select CONCAT('King_', I), CONCAT('Ling_', I), 0;
END WHILE;
-- call prc_mytable_INIT(1);
select * from mytable;
END;
不能少了分号;存储过程中可以返回数据集;
少了分号,如下提示:
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 'END WHILE
-- call mytable_INIT(100);
-- select * from mytable
END' at line 12
在MySQL 中,begin end 语句块,不支持的;
通常begin-end用于定义一组语句块,在各大数据库中的客户端工具中可直接调用,但在mysql中不可用。begin-end、流程控制语句、局部变量只能用于函数、存储过程内部、游标、触发器的定义内部。