我得到错误:
ORA-03001: unimplemented feature
ORA-06512: at "SYS.CHANGE_SSAN", line 127
ORA-06512: at line 2
Process exited.
在这一行:
alter_constraints_disable(hosm_list.hosm);
这是程序:
PROCEDURE alter_constraints_disable (hosm_cd IN VARCHAR2)
IS
BEGIN
for constraint_list IN (select table_name, constraint_name
from dba_constraints
where owner=hosm_cd
and constraint_name in ('List of constraints removed for space.'))
LOOP
execute immediate 'alter table '||hosm_cd||'.'||constraint_list.table_name||' DISABLE constraint '||constraint_list.constraint_name;
END LOOP;
END;
问题似乎来自下一行,而不是调用alter_constraints_disable。
执行立即'select person_id批量收集到'_ | hosm_list.hosm ||'。dod_per命令中的dup_ssan由1 asc';
我是否缺少关于批量收集的内容
答案 0 :(得分:3)
更好的异常处理将准确揭示导致错误的原因。运行此修改版本,然后发布输出。
CREATE OR REPLACE PROCEDURE alter_constraints_disable (hosm_cd IN VARCHAR2)
IS
BEGIN
for constraint_list IN (select table_name, constraint_name
from dba_constraints
where owner=hosm_cd
and constraint_name in ('List of constraints removed for space.'))
LOOP
DECLARE
v_sql varchar2(32767);
BEGIN
execute immediate 'alter table '||hosm_cd||'.'||constraint_list.table_name||
' DISABLE constraint '||constraint_list.constraint_name;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('Error with '||constraint_list.table_name||'.'||
constraint_list.constraint_name);
v_sql := dbms_metadata.get_ddl('TABLE', constraint_list.table_name, hosm_cd);
dbms_output.put_line('Table that caused the error:'||chr(10)||v_sql);
raise;
END;
END LOOP;
END;
/
<强>更新强>
bulk collect into
不应位于动态SQL字符串中。这是一个例子:
create table dod_per as select level person_id from dual connect by level <= 100;
declare
type dup_ssan_type is table of number;
dup_ssan dup_ssan_type;
v_owner varchar2(30) := user;
begin
execute immediate 'select person_id from '||v_owner||'.dod_per order by 1 asc'
bulk collect into dup_ssan;
end;
/
答案 1 :(得分:1)
DBA_CONSTRAINTS仅适用于具有DBA角色的用户。尝试使用ALL_CONSTRAINTS或USER_CONSTRAINTS。还要确保执行该过程的用户具有ALTER CONSTRAINT权限。
您使用的是哪个版本的Oracle?如果是快递版,那么一些功能将无法启用,因为您需要许可证,但据我记忆,禁用/启用约束不是其中之一。
答案 2 :(得分:1)
有趣的是,当我的查询有一个带有额外尾随双引号的标识符时,我也通过ODP.NET提供程序收到此错误(类似这样)
SELECT "Field1" "Alias1", "Field2" "Alias2"
FROM "SomeSchema"."SomeTable"" -- <- extra quote
WHERE "SomeField" = 'SomeCriteria'
简单错误的奇怪错误。