我在从shell脚本直接调用SQL命令时遇到问题。我的shell脚本包含以下命令:
set x = `sqlplus -S $ISLK_ORACLE_UID` <<EOF
delete from rc where rcd_id = 1 ;
update rcd set standard = 'Test_DB7' where id = 1 ;
delete from rc where rcd_id = 2 ;
update rcd set standard = '700' where id = 2 ;
delete from rc where rcd_id = 5 ;
update rcd set standard = 'DB7' where id = 5 ;
delete from rc where rcd_id = 998 ;
update rcd set standard = '2001-2050' where id = 998 ;
delete from rc where rcd_id=3004 ;
begin
for fd_rec in (select * from fd)
loop
insert into rc values(1008, 1, fd_rec.id, 'islk.am@swisscom.com') ;
end loop ;
end ;
commit;
EOF
单个命令(删除,更新)完成没有任何问题,但似乎没有执行thw循环(语句后没有插入)。有谁知道问题可能是什么?
提前多多感谢 最好的祝愿 约尔格
答案 0 :(得分:0)
您可以使用单个SQL语句重写循环:
insert into rc select 1008, 1, id, 'islk.am@swisscom.com' from fd;
这对我来说更具可读性和效率,因为它不使用PL / SQL和循环,而只是依赖于纯SQL。