求高手指点

[复制链接]
查看11 | 回复6 | 2008-1-21 16:50:24 | 显示全部楼层 |阅读模式
declare
type v_ar is varray(4000) of varchar2(4000);
my_ar v_ar:=v_ar
(mstart_time1,mstart_time2,mstart_time3,mstart_time4,mstart_time5,mstart_time6,mstart_time7,mstart_time8,mstart_time9,mstart_time10,
mstart_time11,mstart_time12,mstart_time13,mstart_time14,mstart_time15,mstart_time16,mstart_time17,mstart_time18,mstart_time19,mstart_time20,
mstart_time21,mstart_time22,mstart_time23,mstart_time24,mstart_time25,mstart_time26,mstart_time27,mstart_time28,mstart_time29,mstart_time30,
mstart_time31,mstart_time32,mstart_time33,mstart_time34,mstart_time35);
begin
for i in 1..my_ar.count
loop

Execute Immediate'insert into test_zouk(diff_time,ins_time)values(my_ar(i),sysdate)';

commit;
end loop;
end;
上面代码能编译,可是在过程里面无法执行,为什么啊
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
错误信息?
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
没有错误信息,运行到动态脚本直接抛出异常,不知道为什么
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
异常信息呢?
我猜,是不是你那个varray(4000)惹的祸?实际上你没有这么多个成员,可能导致下标溢出之类的问题(没有测试过,不敢确定)
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
呵呵,my_ar(i)是这个东西惹的祸,它是变量,在动态脚本里面要特别标识一下,谢谢你啊
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
绑定变量 用using就好了
Execute Immediate'insert into test_zouk(diff_time,ins_time)values(:a,:b)' using my_ar(i),sysdate;
回复

使用道具 举报

千问 | 2008-1-21 16:50:24 | 显示全部楼层
为什么用动态呢?改用静态SQL和FORALL.
不要在半中间提交事务。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行