tags:

views:

215

answers:

4

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;

A: 

You can download SQL Developer and use its debugger (it is free).

See here: http://www.oracle.com/technology/software/products/sql/index.html

tuinstoel
+1  A: 

I found something:

See here: http://petermag.blogspot.com/2008/01/export-datapump-how-to-do-via-plsql.html

You get an invalid argument error error when the dump file already exists.

tuinstoel
A: 

Thanks there chap. I have continued debugging and have nailed it down to one line..

DBMS_DATAPUMP.METADATA_FILTER(h1, 'SCHEMA_LIST','''speccs_web_test''', NULL, NULL);

This is the one. Comment it out and all is swell. The error is indicating one of these values is not valid and I would hazard a guess it's the odd looking '''speccs_web_test''' but searches seem to indicate this is correct, this is because that parameter is a list and haven can be '(''name'', ''name''); which translates to ('name', 'name') a valid format for an IN list.

I'll probably sort it in a minute or two but you think i'd of nailed it hours ago :)

Robert
A: 

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 ;)

Robert