CREATE PROCEDURE device()
BEGIN
DECLARE pu_id char;
DECLARE pu_id_base char;
DECLARE pu_info char;
DECLARE pu_info_base char;
DECLARE index int;
DECLARE count int;
SET pu_id_base='JXJ-IPC-';
SET pu_info_base='IPC_';
SET index=00000001;
SET count=00001000;
SET pu_id=concat(pu_id_base,cast(index as char));
SET pu_info=concat(pu_info_base,cast(index as char));
WHILE(index<count) DO
insert into dev_configure_table values(pu_id,'DM-00001',pu_info,3,2,'JXJ','MDS-V-001',1);
SET index=index+1;
END WHILE;
END
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 'index int;
DECLARE count int;
SET pu_id_base='JXJ-IPC-';
SET pu_info_base='IPC_'' at line 7
BEGIN
DECLARE pu_id char;
DECLARE pu_id_base char;
DECLARE pu_info char;
DECLARE pu_info_base char;
DECLARE index int;
DECLARE count int;
SET pu_id_base='JXJ-IPC-';
SET pu_info_base='IPC_';
SET index=00000001;
SET count=00001000;
SET pu_id=concat(pu_id_base,cast(index as char));
SET pu_info=concat(pu_info_base,cast(index as char));
WHILE(index<count) DO
insert into dev_configure_table values(pu_id,'DM-00001',pu_info,3,2,'JXJ','MDS-V-001',1);
SET index=index+1;
END WHILE;
END
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 'index int;
DECLARE count int;
SET pu_id_base='JXJ-IPC-';
SET pu_info_base='IPC_'' at line 7
DROP PROCEDURE IF EXISTS device$$
CREATE PROCEDURE device()
BEGIN
DECLARE pu_id CHAR(10);
DECLARE pu_id_base CHAR(10);
DECLARE pu_info CHAR(10);
DECLARE pu_info_base CHAR(10);
DECLARE `Index` INT;
DECLARE `count` INT;
SET pu_id_base='JXJ-IPC-';
SET pu_info_base='IPC_';
SET `index`=00000001;
SET `count`=00001000;
SET pu_id=CONCAT(pu_id_base,CAST(`index` AS CHAR));
SET pu_info=CONCAT(pu_info_base,CAST(`index` AS CHAR));
WHILE(`index`<`count`) DO
INSERT INTO dev_configure_table VALUES(pu_id,'DM-00001',pu_info,3,2,'JXJ','MDS-V-001',1);
SET `index`=`index`+1;
END WHILE;
END$$
DELIMITER ;
不要用保留字段做变量名