兄弟,这是更新原有数据,而不是插入新数据,表述要准确,使用关联更新即可
update
sis
a
set
a.sid=(select
outid
from
b_cust
b
where
b.idcardno=a.cardno
where
rownum=1)
where
exists
(select
1
from
b_cust
c
where
c.idcardno=a.cardno)
LZ的意思是查出b_cust表中的b_cust.idcardno=sis.cardno的所有记录中的outid插入到sis表中对应的sid列吧
用游标来做试试:
create
or
replace
procedure
pro_test
as
cursor
cur_test
is
select
outid,idcardno
from
b_cust,sis
where
idcardno=cardno;
begin
for
I
in
cur_test
loop
update
sis
set
sid=I.outid
where
cardno=I.idcardno;
end
loop;
end;
/
exec
pro_test;
楼下的哥们我知道这是update操作,确实是我表述不清楚了。。。汗。。