mysql> create procedure p_file_t()
    -> begin
    -> declare a int 
    -> set a=1;
ERROR 1064 (42000): 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 'int 
set a=1' at line 3
mysql> while a<3 do
    -> insert into drbd_t(hash,path) values(“abcd123456”, “/192.168.250.100/file”);
ERROR 1064 (42000): 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 'while a<3 do
insert into drbd_t(hash,path) values(“abcd123456”, “/192.168.' at line 1
mysql> set a=a+1;
ERROR 1193 (HY000): Unknown system variable 'a'
mysql> end while;
ERROR 1064 (42000): 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' at line 1

解决方案 »

  1.   


    把你的所有sql块贴出来,不要带-> 和mysql>的。
      

  2.   

    create procedure p_file_t()
    begin
    declare a int 
    set a=1;
    while a<3 do
    insert into drbd_t(hash,path) values(“abcd123456”, “/192.168.250.100/file”);
    set a=a+1;
    end while;
    end;
      

  3.   

    delimiter $$
    create procedure p_file_t()
    begin
    ...
    end $$
    delimiter ;
      

  4.   

     delimiter $$
    create procedure p_file_t()
    begin
      declare a int;
      set a=1;
      loop1:while a<3 do
             insert into drbd_t(hash,path) values('abcd123456', '/192.168.250.100/file');
            select a;
      set a=a+1;
      end while loop1;
     end $$