1

我尝试通过DBMS_METADATA包更改数据库结构,但出现错误。

这是我使用的包中的函数:

FUNCTION putxml(
  alterxml    IN  CLOB,
  sub_res     OUT NOCOPY sys.ku$_SubmitResults
)
RETURN BOOLEAN
IS
  ret_val             BOOLEAN := true;
  openw_handle        NUMBER;
  transform_handle    NUMBER;
BEGIN
  openw_handle := DBMS_METADATA.openw ('TABLE');
  transform_handle := DBMS_METADATA.add_transform (openw_handle, 'ALTERXML');
  dbms_output.put_line(alterxml);
  ret_val := DBMS_METADATA.put(openw_handle, alterxml, 0, sub_res);
  DBMS_METADATA.close (openw_handle);
  return ret_val;
END;

这是一个 XML:

<ALTER_XML xmlns="http://xmlns.oracle.com/ku" version="1.0">
   <OBJECT_TYPE>TABLE</OBJECT_TYPE>
   <OBJECT1>
      <SCHEMA>GLOBALREF</SCHEMA>
      <NAME>EDO_DOC_OUT</NAME>
   </OBJECT1>
   <OBJECT2>
      <SCHEMA>GLOBALREF</SCHEMA>
      <NAME>EDO_DOC_OUT</NAME>
   </OBJECT2>
   <ALTER_LIST>
      <ALTER_LIST_ITEM>
         <PARSE_LIST>
            <PARSE_LIST_ITEM>
               <ITEM>NAME</ITEM>
               <VALUE>AUTHOR</VALUE>
            </PARSE_LIST_ITEM>
            <PARSE_LIST_ITEM>
               <ITEM>CLAUSE_TYPE</ITEM>
               <VALUE>ADD_COLUMN</VALUE>
            </PARSE_LIST_ITEM>
         </PARSE_LIST>
         <SQL_LIST>
            <SQL_LIST_ITEM>
               <TEXT>ALTER TABLE "GLOBALREF"."EDO_DOC_OUT" ADD ("AUTHOR" VARCHAR2(50))</TEXT>
            </SQL_LIST_ITEM>
         </SQL_LIST>
      </ALTER_LIST_ITEM>
   </ALTER_LIST>
</ALTER_XML>

这是版本信息:

BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Release 12.1.0.1.0 - 64bit Production                                 0
PL/SQL Release 12.1.0.1.0 - Production                                                    0
CORE    12.1.0.1.0  Production                                                            0
TNS for 64-bit Windows: Version 12.1.0.1.0 - Production                                   0
NLSRTL Version 12.1.0.1.0 - Production                                                    0

这是一个错误:

ORA-31607: function PUT (CLOB) is inconsistent with transform.
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_METADATA", line 5189
ORA-06512: at "SYS.DBMS_METADATA", line 5315
ORA-06512: at "SYS.DBMS_METADATA", line 10870
ORA-06512: at "ADMIN.PKG_SYNC", line 90
ORA-06512: at "ADMIN.PKG_SYNC", line 143
ORA-06512: at "ADMIN.PKG_SYNC", line 184
ORA-06512: at line 7
31607. 00000 -  "function %s is inconsistent with transform."
*Cause:    Either (1) FETCH_XML was called when the "DDL" transform
           was specified, or (2) FETCH_DDL was called when the
           "DDL" transform was omitted.
*Action:   Correct the program.

我尝试了DBMS_METADATA.add_transform (openw_handle, 'ALTERXML')有无...

4

0 回答 0