2

任何人都可以帮助我的数据泵导出。我尝试了很多组合。但是,我总是得到:

ORA-39001: invalid argument value
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 4932
ORA-06512: at "SYS.DBMS_DATAPUMP", line 5768
ORA-06512: at line 38

对此有何建议?

CREATE TABLE foo
(
  bar VARCHAR2(10)
);

INSERT INTO FOO VALUES('hello');
INSERT INTO FOO VALUES('world');
COMMIT;


create or replace package pkg
 is
  function tst(p_val varchar2) return varchar2;
end pkg;
/

create or replace package body pkg
 as
function tst(p_val varchar2) return varchar2 is
begin
 return p_val;
end;
end pkg;
/



DECLARE 
  h1 NUMBER;
  l_status varchar2(200);
BEGIN

    h1 := DBMS_DATAPUMP.OPEN(
      operation => 'EXPORT', 
      job_mode => 'TABLE', 
      remote_link => NULL,
      job_name => 'exp_1', 
      version => 'LATEST'
    );

    DBMS_DATAPUMP.ADD_FILE(
      handle => h1, 
      filename => 'export.dmp', 
      reusefile => 1,
      directory => 'DBOUT',
      filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE);
      
    DBMS_DATAPUMP.ADD_FILE(
      handle => h1, 
      filename => 'export.log', 
      reusefile => 1,
      directory => 'DBOUT',
      filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE
    );

    DBMS_DATAPUMP.METADATA_FILTER(
      handle => h1,
      name => 'NAME_EXPR',
      value => 'IN (SELECT table_name FROM user_tables WHERE table_name LIKE ''FOO%'')',
      object_type => 'TABLE'
    );

    DBMS_DATAPUMP.DATA_REMAP(
      handle => h1, 
      name => 'COLUMN_FUNCTION', 
      table_name => 'FOO', 
      column => 'BAR', 
      function => 'pkg.tst'
    );

    
   DBMS_DATAPUMP.start_job(h1);
   DBMS_DATAPUMP.wait_for_job(h1, l_status);
   dbms_output.put_line( l_status );

END;
/

关于文档,它应该可以工作。不?

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/arpls/DBMS_DATAPUMP.html#GUID-2C61513F-9040-4CE3-8C22-ED1FA5FF81DD

任何建议都非常受欢迎,

问候,

4

1 回答 1

1

FUNCTION参数必须是正确的大小写,并且参数SCHEMA必须被包含并且也必须是正确的大小写。这个过程调用对我有用:

DBMS_DATAPUMP.DATA_REMAP(
  handle => h1, 
  name => 'COLUMN_FUNCTION', 
  table_name => 'FOO', 
  column => 'BAR', 
  function => 'PKG.TST',
  schema => user
);

文档中没有提到这些限制,所以我会说您的原始代码是正确的,并且这种行为是一个错误。

于 2021-01-16T16:56:38.297 回答