mysql存储过程转移ecshop属性规格

2013-03-25 14:16 来源:www.chinab4c.com 作者:ecshop专家

     mysql存储过程转移ecshop属性规格,我们可以通过对mysql的处理来达到批量对ecshop的商品属性规格进行处理。

create procedure att()
BEGIN
declare cat_id1     int default 0;
declare id int default 0;
declare done int default 0;
declare curl cursor for select ext_id,cat_id from ecs_goods_ext_fields0;
declare continue handler for not found set done=1;
open curl;
eloop:LOOP
fetch curl into id,cat_id1;
if done=1 THEN
leave eloop;
end if;
if (cat_id1%10 = 0) then
insert into ecs_goods_attr_fields0 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 1) then
insert into ecs_goods_attr_fields1 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 2) then
insert into ecs_goods_attr_fields2 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 3) then
insert into ecs_goods_attr_fields3 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 4) then
insert into ecs_goods_attr_fields4 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 5) then
insert into ecs_goods_attr_fields5 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 6) then
insert into ecs_goods_attr_fields6 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 7) then
insert into ecs_goods_attr_fields7 select * from ecs_goods_ext_fields0 where ext_id=id;
elseif (cat_id1%10 = 8) then
insert into ecs_goods_attr_fields8 select * from ecs_goods_ext_fields0 where ext_id=id;
else
insert into ecs_goods_attr_fields9 select * from ecs_goods_ext_fields0 where ext_id=id;
end if;
end loop eloop;

close curl;
end;

   来源:http://www.chinab4c.com