我有以下存储过程
CREATE PROCEDURE `update_ordenes`()
BEGIN
DECLARE record CURSOR FOR
SELECT ordenes.idorden, ordenes.idafiliado
FROM ordenes, afiliados
WHERE afiliados.idafiliado = ordenes.idafiliado;
OPEN record;
REPEAT
FETCH record INTO @id_orden, @id_afil_viejo;
INSERT INTO afil2(nombre, apellido, documento)
(SELECT nombre, apellido, documento
FROM afiliados
WHERE idafiliado = @id_afil_viejo);
SET @last_id = (SELECT id FROM afil2 ORDER BY id DESC LIMIT 1);
UPDATE ordenes
SET afil2 = @last_id,
ordenes.idafiliado = NULL
WHERE ordenes.idafiliado = @id_afil_viejo
AND ordenes.idorden = @orden_id;
UNTIL done END REPEAT;
END
出于某种原因,我在行出现语法错误FETCH record INTO @id_orden, @id_afil_viejo;
在mysql 文档中我可以运行SELECT id, data INTO @x, @y FROM test.t1 LIMIT 1;
. 是使用中的问题FETCH
吗?或有什么问题?