以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教,如何将递归的结果添加到后台表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=8276) |
-- 作者:唐尸三摆手 -- 发布时间:2010/9/27 9:16:00 -- 请教,如何将递归的结果添加到后台表 ; with cte As (select aec00000.planid,abe00000.*,cast(abe00000.num as numeric(18,4)) As CalcNum from abe00000 join aec00000 on abe00000.parentitem = aec00000.itemcode join eba00000 on aec00000.id_contract = eba00000.id_contract where aec00000.planid =\'0000104442\' union all select cte.planid,a.*,cast(a.num * cte.CalcNum as numeric(18,4))from abe00000 a Join cte on a.parentitem = cte.childitem) select a.planid,d.requiredate,a.parentitem,a.childitem,a.CalcNum*d.plannum as totalnum from cte a,aec00000 d where a.planid=d.planid union all Select planid,requiredate,itemcode As parentitem,itemcode As childitem,plannum As totalnum from aec00000 where planid =\'0000104442\'
这段递归语句是正确的,现在希望将上述的查询结果添加到后台sql数据库的"表A"中,请教如何写代码,试了很多次,总是不成功,假设数据源为ERP |
-- 作者:狐狸爸爸 -- 发布时间:2010/9/27 9:22:00 -- 用上面的语句生成查询表,然后逐行读取,逐行写入后台的表 |
-- 作者:唐尸三摆手 -- 发布时间:2010/9/27 11:06:00 -- 为什么直接用insert into 不可以呢 |
-- 作者:狐狸爸爸 -- 发布时间:2010/9/27 11:26:00 -- 说到Insert into ,这个你比我在行啊
|
-- 作者:唐尸三摆手 -- 发布时间:2010/9/27 13:12:00 -- 这个嘛 ![]() |