Question

Oracle 10G datapump

Asked by: fireword

Hi
I have an Oracle 10G database where we currently import data from another 10G database using the impdp facility initiated by a unix shell script. This works fine and takes about 40 minutes.
Later in the year we have to migrate onto another platform where we will not be able to use this method.
I am investigating using the dbms_datapump utility from within pl/sql and have hit on a couple of problems.
Problem 1 is that trying to import the data within a named PL/SQL procedure fails with the NO_SUCH_JOB error. However, if i use the exact same code within an anonymous pl/sql block then the code runs to completion and the data is imported.
Problem 2 is that although the import worked in the anonymous pl/sql block it took 15 hours to complete.

Any ideas on getting it to execute within a named pl/sql procedure and achieving an execution time in keeping with it being called externally thru impdp.
Regards

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-01-30 at 02:33:14ID24097871
Tags

Oracle

,

datapump

,

impdp

,

PL/SQL

Topics

Oracle CRM

,

Oracle 10.x

,

PL / SQL

Participating Experts
2
Points
250
Comments
15

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Oracle´s dbms estructure
    I am making a investigation about Oracle and I need some help. I am trying to findout about the layer independences in Oracle. To be a little bit more specific: I would like to know if when i make a new relation between two tables, does my existing views change?? and if I ...
  2. Oracle 8i DBMS Job Scheduling
    Hi. We want to schedule a PL/SQL procedure to run daily. Using the Oracle 8i DBMS Scheduler we have attempted to setup this task so that it runs at 5am every day. The job fails to run automatically at the specified time, however the job can be forced to run using DBMS job ...
  3. ORACLE DBMS JOB
    This is with regards to the DBMS_JOB utility in ORACLE. I need to run a job at 10:00 AM on all days. The problem is that iam not able to specify the exact date as such. I can either set the next date to some currentdate+x number of hours/monutes/seconds. But ia not able to ps...
  4. What Oracle package can be used to set a role for a user d…
    What Oracle package can be used to set a role for a user dynamically within an anonymous PL/SQL block? Choice 1 DBMS_ROLE Choice 2 DBMS_SESSION Choice 3 DBMS_USER Choice 4 DBMS_UTILITY Choice 5 Oracle does not provide a package for this.
  5. Oracle dbms_job ?
    Can I run a Job in oracle as we have a facility in MS SQL 2000.
  6. dbms_pipe in Oracle--Urgent
    Can someone please give me an example of dbms_pipe packeage in Oracle

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: schwertnerPosted on 2009-01-30 at 03:26:55ID: 23507053

I use PL/SQL data pump API for third year and it works perfect.

PROCEDURE phr_impdp(p_dump VARCHAR2, p_dir VARCHAR2) IS
  l_dp_handle       NUMBER;
  l_last_job_state  VARCHAR2(30) := 'UNDEFINED';
  l_job_state       VARCHAR2(30) := 'UNDEFINED';
  l_sts             KU$_STATUS;
  v_date            DATE;
  v_date_part       VARCHAR2(55);
  v_file_dump_name  VARCHAR2(55); 
  v_file_log_name   VARCHAR2(55);
  v_dir             VARCHAR2(55) := upper(p_dir);
  v_value           VARCHAR2(4000) := 'IN (';
  v_first           CHAR := '0';
  v_sid             VARCHAR2(55);
  v_instance        VARCHAR2(55);
  v_host            VARCHAR2(55);
  v_count           INTEGER;
  v_count1          INTEGER;
  v_kill            VARCHAR2(400);
  v_exists          NUMBER;
  error_dir_file    EXCEPTION;
  v_encryption      VARCHAR2(55) := 'walldorf';
  v_sql             VARCHAR2(4000);
  v_error_count     INTEGER;
  v_job_name        VARCHAR2(55); 
  
BEGIN
  
  dbms_output.enable(100000);
  --
  --  Check if the directory is known to Oracle
  --
  check_dir_file(p_dir, p_dump, v_exists);
  IF v_exists <> 1 THEN
     raise error_dir_file;
  END IF;
  --
  dbms_output.put_line('Import of the Dump file '|| p_dump);
  dbms_output.put_line('into the following DB using Oracle:');
 
  -- makes unique name for the  Log file
  SELECT sysdate INTO v_date FROM dual;
  select instance_name into v_sid from v$instance;
  v_date_part := 'ImpDP_' || TO_CHAR(v_date,'MMDDYYYY_HH24MISS') || '_' || v_sid;
  v_job_name := 'PHR_imp' || SUBSTR(v_date_part,18,4);
  v_file_log_name := v_date_part || '.log';  
 
  SELECT instance_name, host_name 
  INTO v_instance, v_host
  FROM v$instance;
  dbms_output.put_line('Instance Name: ' || v_instance);
  dbms_output.put_line('Host Name: ' || v_host);
 
  -- code that does following:
  -- 1. kills all sessions to the particular PHR schemas
  -- 2. drops all PHR7 or NHIF schemas
 
   phr_clrsch('kill','drop','not_change');
 
 
  -- creates entries in the DBMS_DATAPUMP package API
  l_dp_handle := DBMS_DATAPUMP.open(
    operation   => 'IMPORT',
    job_mode    => 'FULL',
    remote_link => NULL,
    job_name    => v_job_name,
    version     => 'LATEST');
 
  DBMS_DATAPUMP.add_file(
    handle    => l_dp_handle,
    filename  => p_dump,
    directory => v_dir,
    filetype  => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE);
 
  DBMS_DATAPUMP.add_file(
    handle    => l_dp_handle,
    filename  => v_file_log_name,
    directory => v_dir,
    filetype  => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
 
  DBMS_DATAPUMP.SET_PARALLEL(
    handle    => l_dp_handle,
    degree    => 4);
 
/* works 11g
  DBMS_DATAPUMP.set_parameter(
    handle => l_dp_handle,
    name   => 'ENCRYPTION_PASSWORD',
    value  =>   v_encryption
                               );
*/
 
  DBMS_DATAPUMP.start_job(l_dp_handle);
 
  DBMS_DATAPUMP.detach(l_dp_handle);
 
  --
  -- Wait the job to finish
  --
 
  syncr(v_job_name);
 
  dbms_output.put_line('Import successfully finished.');
  
EXCEPTION 
  WHEN error_dir_file THEN
     dbms_output.put_line('Errors by the Export encountered.');
     IF v_exists = -1 THEN
        dbms_output.put_line('Wrong Logical Directory ' || p_dir);
     ELSIF v_exists = -2 THEN
        dbms_output.put_line('Wrong Dump File ' || p_dump);
     END IF;
     raise_application_error(-20100, 'Error in phr_expdp!');
  WHEN OTHERS THEN
     dbms_output.put_line('Errors by the Import encountered.');
     dbms_output.put_line(substr(sqlerrm,1,254));
     DBMS_DATAPUMP.stop_job(
        handle => l_dp_handle,
        immediate => 1,
        keep_master => 0);
     DBMS_DATAPUMP.detach(l_dp_handle);
     raise_application_error(-20100, 'Error in  phr_impdp!');
 
END phr_impdp;
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:

Select allOpen in new window

 

by: firewordPosted on 2009-01-30 at 06:41:47ID: 23508596

Hi
Thanks for that, it is very similar to what I'm currently doing but I have taken a couple of tips from your code and applied them to mine to see if it will work.
However without any luck, as before, it will execute from an sqlplus session as an anonymous pl/sql block. But when inside a procedure and called via exec e.g exec p_test_impdp it fails, seemingly because it cannot create the master table required for the job handle.
Is there something in the roles/privileges within Oracle that gives different behavior between anonymous pl/sql and explicit pl/sql?
The error i am getting is :-
ORA-31626: job does not exist
ORA-31633: unable to create master table
"OPS$NIKU_MI.SYS_IMPORT_TABLE_23"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line
95
ORA-06512: at "SYS.KUPV$FT", line 863
ORA-01031: insufficient privileges

 

by: schwertnerPosted on 2009-01-30 at 06:51:41ID: 23508721

The bad news is that it doesnt work on Oracle before 10.2.0.1
On 10.2.01 and higher it works fine under SYS account.
Also the directory should physically exist on the place mentioned,
there should not be logs with the name you use.
It works ...

But your DB (if upgraded) can be non consistent - upgrade software, not upgraded
Data base tables.

 

by: firewordPosted on 2009-01-30 at 07:02:53ID: 23508861

The version of the database is 10.2.0.3
The directory does exist, the extract file i am trying to load using dbms_datadump through PL/SQL is the same as the one we currently load using impdp.

The logs I have specified were created fine when called from an anonymous pl/sql block and the data was imported successfully albeit extremely slow.

 

by: sdstuberPosted on 2009-01-30 at 07:03:43ID: 23508867

I (and Oracle also) highly recommend you do NOT run any application code as SYS.
other than startup/shutdown and installs you should never have to do anything as SYS.
It's a bad practice to get into.

The difference between anonymous pl/sql block and a compiled procedure is, the anonymous block will run with the permissions of whomever is logged in at that time.

The compiled procedure will run with the permissions of the procedure's owner.
And, since dbms_datapump is AUTHID CURRENT_USER, the "current" user will be the procedures' owner, regardless of who invokes it.

 

by: schwertnerPosted on 2009-01-30 at 07:05:42ID: 23508897

Migrating to 10.2.0.3 did you run the catupgrade.sql script to upgrade the
Dictionary?
What says this:

set linesize 10000
SELECT SUBSTR(comp_id,1,15) comp_id, status, SUBSTR(version,1,10)
        version, SUBSTR(comp_name,1,30) comp_name
        FROM dba_registry ORDER BY 1;

If the version of the components CATALOG, CATPROC, XDB (among others) is lower than the patch-set version that you have applied, re-run the script catpatch.sql after a startup migrate. See the readme file of the patch-set for all these mandatory post-installation instructions.


 

by: firewordPosted on 2009-01-30 at 07:30:55ID: 23509187

For Schwertner

Component versions for CATALOG, CATPROC and others are all set to 10.2.0.3.

For Sdstuber

Nothing is running under SYS!
Your comments re AUTHID is very useful. I've put the procedure into a package and defined it as AUTHID CURRENT_USER, the job is currently executing as a named procedure which resolves the first of my problems.
The next issue to resolve is why it should be 22½ times slower loading the same file using dbms_datapump compared with impdp.

 

by: sdstuberPosted on 2009-01-30 at 07:34:46ID: 23509238

are you having network issues between databases while impdp is loading a file you have already transferred to the target server?

 

by: firewordPosted on 2009-01-30 at 07:56:16ID: 23509542

The .dmp file is on the same unix server as the database so I don't think that's an issue

 

by: sdstuberPosted on 2009-01-30 at 08:02:48ID: 23509641

which database?  the target db?  If so, that's probably why it's so fast,  it's loading directly opposed to dbms_datapump which must negotiate sqlnet traffic

 

by: firewordPosted on 2009-01-30 at 08:23:19ID: 23509905

yep, the target db is on the same server.
I'm running it this time with a parallel option and it does appear to be doing lots more than it was yesterday.  There is one table that is over 6gb in size that takes the bulk of the time.
will leave it running and info later/

 

by: schwertnerPosted on 2009-01-30 at 09:03:42ID: 23510428

If you see ALERT<sid>.LOG file you will see the reason.
I see it right now.
You will see delay of ONLINE REDO LOF switch because of
noncompleted checkpoint.
This causes the error.
In this case you have to increase the number of the online redo log
groups and to separate them on different disk device.
The database and the dump file also should be separated.
I know this issue very good, if you run 10.2.0.4 you will see
also the a lot of messages that a disk operation uses more then 500 msec.
to finish.
Simply your disk 'farm" is overloaded.

 

by: firewordPosted on 2009-01-30 at 10:51:45ID: 23511518

Hi Schwertner

Thanks for that, I am not the DBA so can't access the alert logs. I will raise your points with the DBA next week.
One of the reasons I'm looking at using pl/sql dbms_datapump rather than impdp is that we are migrating the database onto a new server where we won't have the same access to be able to tun impdp. The likelihood here is that the actual extract dump file will be in a different location to the database so that issue will resolve itself, however I'm not able to test this directly and am really just doing proof of concept development at the moment.

 

by: schwertnerPosted on 2009-01-30 at 12:14:26ID: 23512413

Data Pump works ONLY on the server.
So everything is there - no option.
But I programmed a procedure that reads the files in the directory and
delivers the user the Data Pump log file.
Be aware that DBMS_DATAPUMP enables only a part of the parameters
of EXPDP and IMPDP.
Be aware that up  to 10.2.0.3 due bugs NLS character set transformations do not work with Data Pump. Possibly 10.2.0.4 will be better.

 

by: firewordPosted on 2009-02-02 at 02:24:29ID: 31540882

Each of the experts provided information that enabled me to progress further with the problems i was encountering than i had been able to.
 

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...