高分求一存储过程,各位高手帮忙~~~~~~~~~~~~!
表1 表2
________________ ___________
a b c d a e
---------------- -------------
1 2 3 4 1 4
2 2 5 5 2 5
3 2 4 6 3 6
表3 表4
_______________ _______________
w f e b W F
--------------- ---------------
1 2 1 2 _______________
2 2 2 2 _______________
3 4 2 4 _______________
我想循环的根据表1中 a 取得表2中的 e 值。然后再根据表1中 a 对应的 b 值,根据e,b两个值在表3中取得记录插入到表4中。请问怎么实现???分不够可以再加。谢谢了!
问题点数:100、回复次数:7Top
1 楼wendi(沉睡)回复于 2005-12-01 14:51:01 得分 0
晕,表结构没显示好,再贴一边表结构。
表1
________________
a b c d
----------------
1 2 3 4
2 2 5 5
3 2 4 6
表2
___________
a e
-----------
1 4
2 5
3 6
表3
_______________
w f e b
---------------
1 2 1 2
2 2 2 2
3 4 2 4
表4
_____________
W F
-------------Top
2 楼waterfirer(水清)回复于 2005-12-01 14:57:09 得分 60
insert into 表4
(select w,f from 表1 a,表2 b,表3 c where a.a=b.a and b.e=c.e and a.b=c.b)Top
3 楼ab5669(王长林)回复于 2005-12-01 14:58:49 得分 20
insert into 表4 (w,f)
select w,f from 表3 ,表1
where e=(select e from 表2 where a= 表1.a) and b=表1.bTop
4 楼wendi(沉睡)回复于 2005-12-01 15:10:10 得分 0
谢谢各位,我关键是想知道是怎么循环的把值取得然后插进去。这个循环也是要在存储过程中实现的。Top
5 楼waterfirer(水清)回复于 2005-12-01 15:25:05 得分 0
为什么要作循环?
要求?
cursor c_test is
select w,f from 表1 a,表2 b,表3 c where a.a=b.a and b.e=c.e and a.b=c.b;
for c_get_test in c_test loop
insert into 表4 values(c_get_test.w,c_get_test.f);
end loop;Top
6 楼BurubBiancheng(步入边城(编程))回复于 2005-12-01 15:33:22 得分 20
Insert Into tab4
Select w,f From tab3 Where (tab3.e,tab3.b) In
(Select e,b From tab1,tab2 Where tab1.a=tab2.a);
Insert Into tab4
Select w,f From tab1,tab2,tab3 Where
tab1.a=tab2.a And tab1.b=tab3.b And tab2.e=tab3.e;Top
7 楼wendi(沉睡)回复于 2005-12-01 15:46:03 得分 0
谢谢各位。因为实际的表结构比这个复杂的多。我还有值需要根据表1中的a字段值在其他表中取得数据插入表4。哎。写到这里我都搞糊涂了。我先看下。Top




