superwang001 发表于 2011-9-9 10:15:35

解决一个mysql过程的问题

原mysql过程语句:

DELIMITER //
CREATE PROCEDURE TestWhile()
    BEGIN
      DECLARE v_index INT;
        DECLARE account INT;
       DECLARE passwd INT;
DECLARE isLdapUser INT;
      SET isLdapUser = 0;
   
   WHILE v_index < 5 DO
       
        INSERT INTO psp_sys_user
        (
        sqn,account,passwd,isLdapUser
        QUERY
        )
        VALUES(v_index,account,passwd,0);
        SET account=account+1;
        SET passwd=passwd+1;
       SET v_index = v_index + 1;
    END WHILE;

END//

执行CALL TestWhile();报如下错误

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 'QUERY
)
VALUES(v_index,account,passwd,0);
SET account=account+1;
SET passwd=' at line 14

修改:
去掉query,执行CALL TestWhile();没有插入结果

修改:
初始化三个变量
      DECLARE v_index INT;
        DECLARE account INT;
       DECLARE passwd INT;

再执行,成功!
页: [1]
查看完整版本: 解决一个mysql过程的问题