oracle表a字段赋值给表b,Oracle中Cursor, A表a1字段值复制到B表b1字段

?

不同表,字段赋值:

table_a 和table_b 两个表的code相关联, 把talbe_bd.name 属性值复制到table_a.name,

declare

cursor css1 is

select id,code from table_a;

cursor css2 is

select id,code,name from table_b;

begin

for cs1 in css1

loop

for cs2 in css2

loop

if cs1.code = cs2.code and cs1.id = cs2.id

update table_a a set a.name = cs2.name where a.code = cs2.code;

end if;

end loop;

end loop;

commit;

end;

?

相同表字段赋值:

table_a表, 把code1的字段值复制到code2字段里面

declare

cursor css1 is

select id from table_a;

cursor css2 is

select id,code1 from table_a;

begin

for cs1 in css1

loop

for cs2 in css2

loop

if cs1.id = cs2.id

update table_a a set a.code2 = cs2.code1 where a.id = cs2.id;

end if;

end loop;

end loop;

commit;

end;

?

?

?

原文:http://davidhhs.iteye.com/blog/2246502

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值