MySQL procedure
时间:2010-03-11 来源:xylonw
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`myinsert` $$
create procedure `test`.`myinsert`()
begin
declare id int;
declare size long;
declare en longtext;
declare es longtext;
set id = 1;
select count(*) into size from en_es;
while id <= size do
IF (id%2)=1 then
select en_es.seg into en from en_es where en_es.id = id;
else
select en_es.seg into es from en_es where en_es.id = id;
end if;
IF (id%2)=0 then
##select en,es;
insert into result values(null, en, es);
set en=NULL,es=NULL;
end if;
set id = id + 1;
end while;
end$$
DELIMITER ;
call myinsert();
相关阅读 更多 +