The following PL/SQL will not execute and simply returns ‘Invalid Argument’ as an error. I’ve gone as far as commenting out eavery line one by one and I can vary the error I receive but I cannot get the proc to run as I cannot identify where the error lies and it may well lie in permissions or the executing user but any help will be received gratefully. Here’s the proc
DECLARE ind NUMBER; -- Loop index h1 NUMBER; -- Data Pump job handle percent_done NUMBER; -- Percentage of job complete job_state VARCHAR2(30); -- To keep track of job state le ku$_LogEntry; -- For WIP and error messages js ku$_JobStatus; -- The job status from get_status jd ku$_JobDesc; -- The job description from get_status sts ku$_Status; -- The status object returned by get_status BEGIN h1 := DBMS_DATAPUMP.OPEN('EXPORT','SCHEMA',NULL,'SQL_INSTALLER_01152009_1014','LATEST'); DBMS_DATAPUMP.ADD_FILE(h1,'SQL_INSTALLER_01152009_1014.dmp','ORACLE_SCRIPT_RUNNER_BACKUP',NULL,1); DBMS_DATAPUMP.ADD_FILE(h1,'SQL_INSTALLER_01152009_1014.log','ORACLE_SCRIPT_RUNNER_BACKUP',NULL,3); DBMS_DATAPUMP.METADATA_FILTER(h1, 'SCHEMA_LIST','''speccs_web_test''', NULL, NULL); DBMS_DATAPUMP.START_JOB(h1); percent_done := 0; job_state := 'UNDEFINED'; while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop dbms_datapump.get_status( h1, dbms_datapump.ku$_status_job_error + dbms_datapump.ku$_status_job_status + dbms_datapump.ku$_status_wip, -1, job_state, sts); js := sts.job_status; if js.percent_done != percent_done then percent_done := js.percent_done; end if; if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0) then le := sts.wip; else if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0) then le := sts.error; else le := null; end if; end if; if le is not null then ind := le.FIRST; while ind is not null loop ind := le.NEXT(ind); end loop; end if; end loop; dbms_datapump.detach(h1); END;
For this particular problem it is because the schema_name speccs_web_test is not in upper case. SPECCS_WEB_TEST is fine and the proc is now running 😉