I am rewriting an application, that imports and exports oracle database. I was using imp.exe and exp.exe executed as Processes from code. Now I'm trying to use impdp and expdp instead of them. I studied some samples at https://docs.oracle.com/, however the following code fails at DBMS_DATAPUMP.ADD_FILE.
DECLARE
h2 NUMBER;
BEGIN
h2 := DBMS_DATAPUMP.OPEN('EXPORT','SCHEMA',NULL, 'MYJOB', 'LATEST');
DBMS_DATAPUMP.ADD_FILE(h2,'test1.dmp','datapump_dir');
DBMS_DATAPUMP.METADATA_FILTER(h2,'SCHEMA_EXP','IN (''sc900'')');
DBMS_DATAPUMP.START_JOB(h2);
dbms_datapump.detach(h2);
END;
The error output is
ORA-39001: invalid argument value
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3507
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3756
I am connected as 'sys' and 'datapump_dir' creation statement was successfully executed.
What am i doing wrong? Thanks in advance!
If anyone will be interested in, I found the problem cause. For some reason, it didn't work, even if I specified default directory. However, when I pass null to this parameter, it works. The following code works, the only disadvantage is that I can save to default directory only
DECLARE
h2 NUMBER;
BEGIN
h2 := DBMS_DATAPUMP.OPEN('EXPORT', 'SCHEMA');
DBMS_DATAPUMP.ADD_FILE(h2, 'example0.dmp', null);
DBMS_DATAPUMP.METADATA_FILTER(h2,'SCHEMA_EXPR', q'{IN ('SC900')}');
DBMS_DATAPUMP.START_JOB(h2);
DBMS_DATAPUMP.DETACH(h2);
END;
/