我想將所有記錄從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