架构理念:[简单][高效][可依赖] 管理理念:[价值][勇气][专注]

function in Postgres

CREATE or REPLACE FUNCTION fn_attr_category()
   RETURNS void AS 
$BODY$
declare
    v_tmp_rec    record;
begin
    --获取待补充品类的规格
    for v_tmp_rec in  
        select * from tcim_s_gcmaster where 'COLOR'||categoryid not in (select attrid from TCim_S_GcAttributeSel) and categoryid like 'L%';
    --批量插入明细表
    loop
        insert into TCim_S_GcAttributeSel
        select 
            replace(selectid, 'L00000V', v_tmp_rec.categoryid),selectname,'COLOR'||v_tmp_rec.categoryid as attrid,'N' as isdefault,seqno
         from TCim_S_GcAttributeSel where attrid = 'COLORL00000V';
    end loop;

end
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

 

posted @ 2016-04-14 16:28  文和-Mignet  阅读(292)  评论(0编辑  收藏  举报