3

我收到错误消息:

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 bulk collect into dup_ssan from '||hosm_list.hosm||'.dod_per order by 1 asc';

关于批量收集,我有什么遗漏吗

4

3 回答 3

4

更好的异常处理将准确发现导致错误的原因。运行这个修改后的版本,然后发布输出。

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;
/
于 2013-07-17T04:28:40.217 回答
2

DBA_CONSTRAINTS 仅适用于具有 DBA 角色的用户。尝试使用 ALL_CONSTRAINTS 或 USER_CONSTRAINTS。还要确保执行该过程的用户具有 ALTER CONSTRAINT 权限。

您使用的是什么版本的 Oracle?如果它是快速版,那么某些功能将不会启用,因为您需要许可证,但据我所知,禁用/启用约束不是其中之一。

于 2013-07-16T21:24:42.503 回答
2

有趣的是,当我的查询有一个带有额外尾随双引号的标识符(类似这样)时,我也通过 ODP.NET 提供程序收到了这个错误

SELECT "Field1" "Alias1", "Field2" "Alias2"
FROM "SomeSchema"."SomeTable"" -- <- extra quote
WHERE "SomeField" = 'SomeCriteria'

一个简单的错字的奇怪错误。

于 2016-05-27T13:25:39.810 回答