Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ora-31626 job does not exist

Posted on 2009-07-02
5
Medium Priority
?
3,635 Views
Last Modified: 2013-12-19
I am having a procedure (which was bascially copied from the pl/sql query generated from OEM(maintenance->Export to export files) when you want to export a schema)..

If i run the pl/sql as a script it works in TOAD perfecly fine..however if i create the same script as a procedure it errors out in line...( i am logged in as that schema user and the schema has permissions to read,write on the data pump dump directory)
My aim is to run this procedure as a job and do export at regular intervals.....

ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 911
ORA-06512: at "SYS.DBMS_DATAPUMP", line 4356
ORA-06512: at "TestSchema.TEST_EXPORT", line 30
ORA-06512: at line 2

CREATE OR REPLACE PROCEDURE TestSchema.Test_Export IS
 
BEGIN
declare
  h1   NUMBER;
  dt   VARCHAR2(28);
 
begin
  begin 
  SELECT TO_CHAR(SYSDATE,'YYYYMMDD') INTO dt FROM DUAL;
      h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'TEST_EXPORT', version => 'COMPATIBLE');      ***** error at this line saying job does not exist***********
  end;
  begin 
     dbms_datapump.set_parallel(handle => h1, degree => 1); 
  end;
  begin 
     dbms_datapump.add_file(handle => h1, filename => 'Test_export'||dt||'.LOG', directory => 'DUMP_DIR', filetype => 3); 
  end;
  begin 
     dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 0); 
  end;
  begin 
     dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''TESTSCHEMA'')'); 
  end;
  begin 
     dbms_datapump.add_file(handle => h1, filename => 'Test_export_'||dt||'.DMP', directory => 'DUMP_DIR', filetype => 1); 
  end;
  begin 
     dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1); 
  end;
  begin 
     dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC'); 
  end;
  begin 
     dbms_datapump.set_parameter(handle => h1, name => 'ESTIMATE', value => 'BLOCKS'); 
  end;
  begin 
     dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0); 
  end;
  begin 
     dbms_datapump.detach(handle => h1); 
  end;
end;
 
END Test_Export;
/

Open in new window

0
Comment
Question by:Pra4444
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
gatorvip earned 2000 total points
ID: 24765828
Try to run it as an autonomous transaction, see document # 459419.1 in Metalink
0
 
LVL 12

Author Comment

by:Pra4444
ID: 24766067
added the line..but still got the same error...
0
 
LVL 12

Author Comment

by:Pra4444
ID: 24766112
well this document solved my problem..i had to give specific grant statements to the user...not sure why those particular grants didnt require if its runs as an anonymous block..
you still get the credit you pointed me to look in metalink..

Thanks...
0
 
LVL 12

Author Comment

by:Pra4444
ID: 24766119
315488.1 is the doc ID number..thought i had pasted..but obviously i didnt...
0
 
LVL 20

Expert Comment

by:gatorvip
ID: 24766167
>>not sure why those particular grants didnt require if its runs as an anonymous block..

Actually, this is somewhat of a different issue and it has to do with user privileges. The PL/SQL code uses rights granted to roles, but when you use a procedure you need to grant rights directly to the user.

More specifically, see this link: http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10800/dcimethpls.htm#sthref170

For the compilation of the procedure or package, the owner of the procedure or package must have been explicitly granted the necessary object privileges for all objects referenced within the body of the code. The owner cannot have obtained required privileges through roles.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question