2016-09-13 128 views
1

我試圖修改使用以下命令的Oracle對象的內部number(7,0)屬性:Oracle更改對象?

alter type myObjectFormat 
    modify ATTRIBUTE (
    A NUMBER(7,2)) CASCADE FORCE; 

錯誤:

Error report - 
SQL Error: ORA-06545: PL/SQL: compilation error - compilation aborted 
ORA-06550: line 10, column 32: 
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: 

    exceptions 
ORA-06550: line 0, column 0: 
PLS-00565: MYOBJECTFORMAT must be completed as a potential REF target (object type) 
06545. 00000 - "PL/SQL: compilation error - compilation aborted" 
*Cause: A pl/sql compilation error occurred and the compilation was 
      aborted completely without the compilation unit being written 
      out to the backing store. Unlike ora-06541, the user will always 
      see this error along with the accompaning PLS-nnnnn error messages. 
*Action: See accompanying PLS-nnnnn error messages. 

我的目標如下:

create or replace type myObjectFormat 
as object (
    A number(7,0) 
); 

函數使用(顯然只是一個例子來重新創建錯誤):

CREATE OR REPLACE FUNCTION STACKOVERFLOW RETURN MYOBJECTFORMAT AS 
BEGIN 
    RETURN NULL; 
END STACKOVERFLOW; 

我試圖手動更改對象中的數據類型,但得到錯誤消息Error(1,1): ORA-02303: can't drop or replace a type with type or table dependents. SQLDev advises setting "Drop Type Force" preference。此時要做的「簡單」事情就是放棄使用此對象的函數,進行更改,然後重新創建函數。隨着數據庫的增長,「簡單」的方式將不可行。

甲骨文參考文獻:

Type Evolution

ALTER TYPE Statement

我寧願使用alter類型語句,只是知道我的語法了嗎?在我看來,我的FORCE命令是在不正確的地方。

回答

1

看起來你缺少exceptions_clause

dependent_handling_clause :: =

enter image description here exceptions_clause :: =

enter image description here

Specify FORCE if you want the database to ignore the errors from dependent tables and indexes and log all errors in the specified exception table. The exception table must already have been created by executing the DBMS_UTILITY.CREATE_ALTER_TYPE_ERROR_TABLE procedure.

含義,如果你有FORCE那麼你需要說你想要的異常流入的表。

+0

所以,錯誤仍然存​​在......如果技術上仍然存在「錯誤」,那麼函數如何成功接受這個更改?另外,我用'DBMS_UTILITY.CREATE_ALTER_TYPE_ERROR_TABLE'跳進了未知的水域。我是否必須定義一個模式和表來發送它?任何例子? – TriHard8