我想将所有记录从temp1表复制到另一个表中,我正在使用光标进行此操作。将不同记录从一个表复制到另一个表的光标
DELIMITER //
CREATE PROCEDURE cpyQ()
BEGIN
DECLARE g_id INT DEFAULT 0;
DECLARE v_fn varchar(100);
DECLARE v_ln varchar(100);
DECLARE v_email varchar(100);
declare tcursor for select distinct mailid,fname,lname from temp1;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET flag = 1;
OPEN tcursor;
REPEAT
FETCH cursor into v_fn,v_ln, v_email;
insert into atom(type) values('Person');
SET g_id = LAST_INSERT_ID();
insert into user(id,fname,lname,mailid) values(g_id,v_fname,v_lname,v_email);
END REPEAT;
CLOSE tcursor;
END//
DELIMITER
此代码显示错误
MySQL said: Documentation
#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 'for select distinct mailid,fname,lname from temp1;
DECLARE CONTINUE HANDLE' at line 8
如何解决这个
我的目标是从一个表复制不同的数据到另一个表。我想另一个2表我需要光标 – xrcwrn
http://stackoverflow.com/questions/34309376/store-procedure-to-copy-a-table-to-two-anoter-table我也试过这个代码,但这只是复制到原子表中不是给用户的 – xrcwrn