就是想实现使用存储过程来插入数据 start参数:是来控制从id为几开始插入, max_num是来控制插入的条数
delimiter $$
create procedure insert_user(in start int(10),in max_num int(10))
begin
declare i int default 0;
set autocommit=0;
repeat
set i=i+1;
insert into user_list values((start+i),2,(start+i),md5(123));
until i=max_num;
end repeat;
commit;
end $$
不懂哪里出错了,错误提示如下

解决方案 »

  1.   

    delimiter $$
    create procedure insert_user(start int, max_num int)
    begin
    declare i int default 0;
    set autocommit=0;
    test:repeat
    set i=i+1;
    insert into user_list values((start+i),2,(start+i),md5(123));
    until i=max_num
    end repeat test;
    commit;
    end $$
      

  2.   

    DELIMITER $$
     CREATE PROCEDURE insert_user(IN START INT(10),IN max_num INT(10))
     BEGIN
     DECLARE i INT DEFAULT 0;
     SET autocommit=0;
     WHILE i<max_num DO 
     INSERT INTO user_list VALUES((`start`+i),2,(`start`+i),MD5('123'));
      SET i=i+1;
      END WHILE;
      COMMIT;
     END $$
      

  3.   

    在MYSQL命令行下测试通过
      

  4.   

    只看到多了一个分号 ,其他的暂时不知道,脚本如下 :
    CREATE 
    PROCEDURE insert_user(IN start INT(10), IN `max_num ` INT(10))
    BEGIN
      DECLARE i INT DEFAULT 0;  SET autocommit = 0;
      REPEAT
        SET i = i + 1;
        INSERT INTO user_list VALUES ((start + i), 2, (start + i), md5(123));
       UNTIL i = max_num 
      END REPEAT;
      COMMIT;END
      

  5.   

    那我如果是在wamp环境中的mysql怎么办?,我这是在wamp中的
      

  6.   

    直接贴你的SQL语句和错误信息,不要贴图,以便他人分析。
      

  7.   

    delimiter $$
     create procedure insert_user(start int, max_num int)
     begin
     declare i int default 0;
     set autocommit=0;
     test:repeat
     set i=i+1;
     insert into user_list values((start+i),2,(start+i),md5(123));
     until i=max_num
     end repeat test;
     commit;
     end $$执行上面的语句完,错误信息如下(我是在wamp环境中的mysql执行的,不是命令行)
    —————————————————————————————————————————————————
    错误
    SQL 查询:CREATE PROCEDURE insert_user( START INT, max_num INT ) BEGIN declare i INT DEFAULT 0;SET AUTOCOMMIT =0;test : repeat SET i = i +1;INSERT INTO user_list
    VALUES ((START + i
    ), 2, (START + i
    ), MD5( 123 )
    );until i = max_num END repeat test;COMMIT ;END $$
    MySQL 返回:#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 '$$' at line 11 
    ————————————————————————————————————————————————
      

  8.   

    你可以在图形化界面中的SQL命令行执行创建存储过程脚本 或  ,创建一个后缀为.sql的文件,把创建存储过程脚本复制到里面 ,找到mysql安装目录 ,以DOS方式或sh 方式登录mysql ,使用source 命令导入 存储过程 。
    你也可以 把  “$$ ”换成成 “ ; ”试试看吧 
      

  9.   

    CREATE PROCEDURE insert_user( START INT, max_num INT ) 
    BEGIN
     declare i INT DEFAULT 0;SET AUTOCOMMIT =0;test : repeat SET i = i +1;INSERT INTO user_list
    VALUES ((START + i
    ), 2, (START + i
    ), MD5( 123 )
    );until i = max_num END repeat test;COMMIT ;END;
      

  10.   

    我就是使用wamp中的图形化界面的SQL命令执行的,执行你给的存储过程也出错了
    错误信息如下