我的存储过程
CREATE PROCEDURE v_competition_getlabels(f1 varchar(20))
begin
  if(f1='voc_id') then
  select distinct voc_id,rps_voc from viw_competition_ana;
  else if(f1='cop_id') then
  select distinct cop_id,cop_name from viw_competition_ana;
  end if;
  end if;
end;
Error Code : 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 line4
我在mysql-front 5.1下能执行,可到了phpmyadmin sqlyog工具里就不可以执行,谁能告诉我这个存储过程错在哪里了,谢谢!

解决方案 »

  1.   

    工具里面只需要粘beginend部分吧
      

  2.   

    明白了,高手是怎么练成的——原来是不断的推敲和试验!SQLYOG、PHPMYADMIN一定是老外写的太垃圾,一点都不灵活。
      

  3.   

    没有问题,估计是你根本没标记 delimiter
    mysql> delimiter //
    mysql> CREATE PROCEDURE v_competition_getlabels(f1 varchar(20))
        -> begin
        ->  if(f1='voc_id') then
        ->  select distinct voc_id,rps_voc from viw_competition_ana;
        ->  else if(f1='cop_id') then
        ->  select distinct cop_id,cop_name from viw_competition_ana;
        ->  end if;
        ->  end if;
        -> end;
        -> //
    Query OK, 0 rows affected (0.45 sec)mysql> delimiter ;
    mysql>