错误码:-7184
错误内容:对象定义[%s]被修改,版本检查失败
表的DDL操作将会改变字典对象的版本ID
--创建测试表
create table t1 as select * from dba_objects;
create or replace procedure upd_t1 (edate in varchar2) as
in_date timestamp(6);
cursor c1 is select * from t1;--定义查询t1的游标
tcl t2%rowtype;
begin
in_date := to_date(edate,'yyyymmdd');
execute immediate 'create index idx_t1_01 on t1(object_id,created)';--执行t1的DDL
open c1; --此处打开游标会报"对象定义被修改"
while c1%found
loop
fetch c1 into tcl;
exit when c1%notfound;
update t1 set subobject_name=tcl.object_name where object_id=tcl.object_id and created=in_date;
end loop;
close c1;
commit;
execute immediate 'drop index idx_t1_01';
end;
--调用过程时将会报错"-7184: 对象定义[T1]被修改,版本检查失败"
call ins_t1('20221010');
select * from sysobjects where name='T1';
关注VERSION字段,表示"字典对象的版本",由于在一个PL/SQL执行块中执行了对T1表的DDL,从而改变了T1的字典版本
避免在存储过程中对同一张表进行字典修改操作
文章
阅读量
获赞