DBMS_DATAPUMP. OPEN
HelloI am a newbie in PL/SQL & DATAPUMP!
I tried to generate (OPEN) IMPORT-WORK with:
CREATE OR REPLACE PROCEDURE XX IS
BEGIN
BEGIN
DECLARE
HANDLE1 NUMBER;
BEGIN
HANDLE1 := DBMS_DATAPUMP.OPEN(OPERATION => 'IMPORT',
JOB_MODE => 'SCHEMA',
REMOTE_LINK => 'STRM');
DBMS_OUTPUT.PUT_LINE('HANDLE1 :' || HANDLE1);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('EX_HANDLE1 :' || HANDLE1);
DBMS_OUTPUT.PUT_LINE('Import Error 1 :' || SQLERRM(SQLCODE));
END;
END;
END XX;
and always have the following error after running:SQL> execute xx;
EX_HANDLE1 :
Import Error 1 :ORA-31626: Job ist nicht vorhanden
PL/SQL procedure successfully completed
SQL>
And the handle Variable is empty !What I did wrong?
Help, please!
hqt200475
Published by: hqt200475 on March 29, 2011 03:16
Try with:
l_dp_handle := DBMS_DATAPUMP.OPEN(operation => 'IMPORT',
job_mode => 'SCHEMA',
remote_link => NULL,
job_name => 'IMPORT_JOB',
version => 'COMPATIBLE');
Are you sure remote connection? See the documentation for this parameter and use it.
Tags: Database
Similar Questions
-
DBMS_DATAPUMP.metadata_remap - a matter of REMAP_TABLE.
I want to export SCOTT. DEPT table and imports than HR. DEPT_HR with constraint. I'm using DBMS_METADATA. METADATA_REMAP with REMAP_SCHEMA (to change the schema anme) and REMAP_TABLE (to change the name of the table). I don't know where I am getting the error. It seems that REMAP_SCHEMA is changing all the names of schema successfully, but REMAP_TABLE does not change the name of the table on the constraint. So constraint is not be created. Is there another workaround solution? Here is a small proof of concept:
SQL> --My database version. SQL> ---------------------- SQL> SELECT * FROM v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production SQL> SET SERVEROUT ON SQL> ed Wrote file afiedt.buf 1 DECLARE 2 l_data_pump_handle NUMBER; 3 l_logfilename VARCHAR2(30) := 'DWABI_'||to_char(sysdate, 'DDMMRRRRhh24miss') || '.log'; 4 l_expfilename VARCHAR2(30) := 'DWABI_'||to_char(sysdate, 'DDMMRRRRhh24miss') || '.dmp'; 5 BEGIN 6 l_data_pump_handle:= DBMS_DATAPUMP.OPEN(operation => 'EXPORT', 7 job_mode => 'TABLE', 8 remote_link => NULL, 9 job_name => 'TEST_REMAP_DP', 10 version => 'LATEST'); 11 DBMS_DATAPUMP.ADD_FILE(handle => l_data_pump_handle, 12 filename => l_expfilename, 13 directory => 'SAUBHIK', 14 filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE); 15 DBMS_DATAPUMP.ADD_FILE(handle => l_data_pump_handle, 16 filename => l_logfilename, 17 directory => 'SAUBHIK', 18 filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE); 19 DBMS_DATAPUMP.metadata_filter(handle => l_data_pump_handle, 20 name => 'SCHEMA_EXPR', 21 value =>'= '||''''||'SCOTT'||''''); 22 DBMS_DATAPUMP.metadata_filter(handle => l_data_pump_handle, 23 name => 'NAME_EXPR', 24 value =>'= '||''''||'DEPT'||''''); 25 --We don't need index 26 DBMS_DATAPUMP.metadata_filter(handle => l_data_pump_handle, 27 name => 'EXCLUDE_PATH_EXPR', 28 value =>'=''INDEX'''); 29 -- We don't copy table statistics!! 30 DBMS_DATAPUMP.metadata_filter(handle => l_data_pump_handle, 31 name => 'EXCLUDE_PATH_EXPR', 32 value =>'=''STATISTICS'''); 33 -- We don't copy index statistics either!! 34 DBMS_DATAPUMP.metadata_filter(handle => l_data_pump_handle, 35 name => 'EXCLUDE_PATH_EXPR', 36 value =>'=''INDEX_STATISTICS'''); 37 -- We do not need the data!! 38 DBMS_DATAPUMP.DATA_FILTER( 39 handle => l_data_pump_handle, 40 name => 'INCLUDE_ROWS', 41 value =>0 42 ); 43 -- Start the export now. 44 DBMS_DATAPUMP.start_job(l_data_pump_handle); 45 dbms_output.put_line('Export started....'); 46 -- Detach, it's finish! 47 DBMS_DATAPUMP.detach(l_data_pump_handle); 48 dbms_output.put_line('Export ended....'); 49 EXCEPTION 50 WHEN OTHERS THEN 51 dbms_datapump.stop_job(l_data_pump_handle); 52 RAISE; 53* END; 54 / Export started.... Export ended.... PL/SQL procedure successfully completed. SQL> SELECT * FROM user_datapump_jobs; no rows selected
Now, I'm importing that:
SQL> ed Wrote file afiedt.buf 1 --DWABI_28052015143133.dmp 2 DECLARE 3 l_data_pump_imp_handle NUMBER; 4 l_logfilename VARCHAR2(30) := 'DWABI_'||to_char(sysdate, 'DDMMRRRRhh24miss') || '.log'; 5 ind NUMBER; -- loop index 6 pct_done NUMBER; -- percentage complete 7 job_state VARCHAR2(30); -- track job state 8 le ku$_LogEntry; -- WIP and error messages 9 js ku$_JobStatus; -- job status from get_status 10 jd ku$_JobDesc; -- job description from get_status 11 sts ku$_Status; -- status object returned by get_status 12 BEGIN 13 l_data_pump_imp_handle:= DBMS_DATAPUMP.OPEN(operation => 'IMPORT', 14 job_mode => 'FULL', 15 remote_link => NULL, 16 job_name => 'TEST', 17 version => 'LATEST'); 18 DBMS_DATAPUMP.ADD_FILE(handle => l_data_pump_imp_handle, 19 filename => 'DWABI_28052015143133.dmp', 20 directory => 'SAUBHIK', 21 filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE); 22 DBMS_DATAPUMP.ADD_FILE(handle => l_data_pump_imp_handle, 23 filename => l_logfilename, 24 directory => 'SAUBHIK', 25 filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE); 26 --If table is already there then do not import. 27 dbms_datapump.set_parameter(handle => l_data_pump_imp_handle, 28 name => 'TABLE_EXISTS_ACTION', 29 value =>'SKIP'); 30 -- We need to remap the schema!!. 31 dbms_output.put_line('Changing Schema...'); 32 DBMS_DATAPUMP.METADATA_REMAP ( 33 handle => l_data_pump_imp_handle, 34 name => 'REMAP_SCHEMA', 35 old_value => 'SCOTT', 36 value=>'HR' 37 ); 38 -- We need to remap the table!!. This is not working properly. 39 dbms_output.put_line('Changing Table...'); 40 DBMS_DATAPUMP.METADATA_REMAP ( 41 handle => l_data_pump_imp_handle, 42 name => 'REMAP_TABLE', 43 old_value => 'DEPT', 44 value=>'DEPT_HR', 45 object_type => NULL 46 ); 47 -- Start the import now. 48 DBMS_DATAPUMP.start_job(l_data_pump_imp_handle); 49 -- monitor job 50 pct_done := 0; 51 job_state := 'UNDEFINED'; 52 WHILE (job_state != 'COMPLETED') AND (job_state != 'STOPPED') LOOP 53 dbms_datapump.get_status(l_data_pump_imp_handle, dbms_datapump.ku$_status_job_error + 54 dbms_datapump.ku$_status_job_status + 55 dbms_datapump.ku$_status_wip, -1, job_state, sts); 56 js := sts.job_status; 57 -- If the percentage done changed, display the new value 58 IF js.percent_done != pct_done THEN 59 dbms_output.put_line('*** Job percent done = ' || 60 to_char(js.percent_done)); 61 pct_done := js.percent_done; 62 END IF; 63 -- If any work-in-progress (WIP) or error messages 64 -- were received for the job, display them. 65 IF (BITAND(sts.mask,dbms_datapump.ku$_status_wip) != 0) THEN 66 le := sts.wip; 67 ELSE 68 IF (BITAND(sts.mask,dbms_datapump.ku$_status_job_error) != 0) THEN 69 le := sts.error; 70 ELSE 71 le := NULL; 72 END IF; 73 END IF; 74 IF le IS NOT NULL THEN 75 ind := le.FIRST; 76 WHILE ind IS NOT NULL LOOP 77 dbms_output.put_line(le(ind).LogText); 78 ind := le.NEXT(ind); 79 END LOOP; 80 END IF; 81 --DBMS_LOCK.sleep (10); 82 END LOOP; 83 -- Indicate that the job finished and detach from it. 84 dbms_output.put_line('Job has completed'); 85 -- Detach, it's finish! 86 DBMS_DATAPUMP.detach(l_data_pump_imp_handle); 87 EXCEPTION 88 WHEN OTHERS THEN 89 dbms_datapump.stop_job(l_data_pump_imp_handle); 90 RAISE; 91* END; SQL> / Changing Schema... Changing Table... Master table "SYS"."TEST" successfully loaded/unloaded Starting "SYS"."TEST": Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT ORA-39083: Object type CONSTRAINT failed to create with error: ORA-00942: table or view does not exist Failing sql is: ALTER TABLE "HR"."DEPT" ADD CONSTRAINT "PK_DEPT" PRIMARY KEY ("DEPTNO") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE Job "SYS"."TEST" completed with 1 error(s) at 15:04:02 Job has completed PL/SQL procedure successfully completed. SQL>
If you look at the failing sql code, it is clear that the name of the table in the constraint definition has not changed, but the DEPT_HR table is created in the HR schema without constraint. What's not here?
Post edited by: Massimiliano edited the subject line, because he said as DBMS_METADATA. Changed to DBMS_DATAPUMP.
Hello
This is a bug in 11.2.0.1 I think - please this Ref
Oracle Support Document 1609238.1 (REMAP_TABLE on IMPDP FAILS WITH ORA-942) can be found at: https://support.oracle.com/epmos/faces/DocumentDisplay?id=1609238.1
See you soon,.
Rich
-
DataPump - expdp.open creates tables in the schema
Hello
I use datapump in Oracle 10 g to archive old main schema to another schema partitions.
I noticed that when dbms_datapump.open is called and a new table is created by dbms_datadpump for internal purposes. This is verified in the oracle documentation
http://docs.Oracle.com/CD/B12037_01/AppDev.101/b10802/d_datpmp.htm#997383
Notes on use
- When the task is created, a master table is created for work under the scheme of the appellant in the default tablespace of the appellant. A handful referring to employment is returned that attaches to the current session to use. Once attached, the handle remains valid until that either explicit or implicit detach occurs. The handle is only valid in the session of the appellant. Other handles can be attached to the same task from another session using the
ATTACH
procedure.
Does anyone know if this table can be removed by a call to dbms_datapump Oracle 'clean', or if it has to be cleaned manually.
can confirm that this is what you do
v_job_handle: = DBMS_DATAPUMP. OPEN('EXPORT', 'TABLE', NULL, v_job_name);
-The parallelism 1 value and add the file
DBMS_DATAPUMP. SET_PARALLEL (v_job_handle, 1);
DBMS_DATAPUMP. ADD_FILE(v_job_handle, v_job_name |) '_' || v_partition. PARTITION_NAME | ".dmp", "PARTITION_DUMPS");
-Apply filters to process only a partition in the table
DBMS_DATAPUMP. METADATA_FILTER(v_job_handle, 'SCHEMA_EXPR', 'IN ("SIS_MAIN")');
DBMS_DATAPUMP. METADATA_FILTER(v_job_handle, 'NAME_EXPR', ' AS "' | t_archive_list (i) |) '''');
DBMS_DATAPUMP. DATA_FILTER(v_job_handle, 'PARTITION_EXPR', ' IN ("' | v_partition.partition_name |)) ')', t_archive_list (i), "SIS_MAIN");
-Use statistics (rather than blocks) to estimate the time.
DBMS_DATAPUMP. SET_PARAMETER(v_job_handle, 'ESTIMATE', 'STATISTICS');
-Start the work. An exception is returned if something is not installed correctly.
DBMS_DATAPUMP. START_JOB(v_job_handle);
-The export job should work now. We loop until its finished
v_percent: = 0;
v_job_state: = "UNDEFINED";
WHILE (v_job_state! = 'DONE') and (v_job_state! = "STOPPED") LOOP
DBMS_DATAPUMP.get_Status (v_job_handle,DBMS_DATAPUMP.ku$_status_job_error + DBMS_DATAPUMP.ku$_status_job_status + DBMS_DATAPUMP.ku$_status_wip,-1, v_job_state, m);
js: = sts.job_status;
-As percentage-complete in this loop changes, displays the new value.
IF js.percent_done! = v_percent THEN
v_percent: = js.percent_done;
END IF;
END LOOP;
-Once the work is finished, view the status before you loose work.
PRC_LOG (f1, t_archive_list (i) |) ': Export complete with status: '. v_job_state);
-DBMS_DATAPUMP. Detach (v_job_handle);
-Use STOP_JOB instead of DETACHING otherwise 'master' table that is created when the OPEN is called is not removed.
DBMS_DATAPUMP. STOP_JOB(v_job_handle, 0, 0);
- When the task is created, a master table is created for work under the scheme of the appellant in the default tablespace of the appellant. A handful referring to employment is returned that attaches to the current session to use. Once attached, the handle remains valid until that either explicit or implicit detach occurs. The handle is only valid in the session of the appellant. Other handles can be attached to the same task from another session using the
-
Exclusion DBMS_DATAPUMP
Hello
How to exclude the index, synomys, grants, statistics while making import using DBMS_DATAPUMP.
Could someone pls give me the syntax to exculde these things.
Thank you
JPHi JP,
The problem of single quotes - try this example (just update your schema name as suitable etc.):DECLARE l_dp_handle NUMBER; l_last_job_state VARCHAR2(30) := 'UNDEFINED'; l_job_state VARCHAR2(30) := 'UNDEFINED'; l_sts KU$_STATUS; v_job_state varchar2(4000); BEGIN l_dp_handle := DBMS_DATAPUMP.open(operation => 'EXPORT', job_mode => 'SCHEMA', remote_link => NULL, version => 'LATEST'); DBMS_DATAPUMP.add_file(handle => l_dp_handle, filename => 'test.dmp', directory => 'DATA_PUMP_DIR', reusefile => 1); DBMS_DATAPUMP.add_file(handle => l_dp_handle, filename => 'test.log', directory => 'DATA_PUMP_DIR', filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE, reusefile => 1); DBMS_DATAPUMP.METADATA_FILTER(l_dp_handle, 'SCHEMA_LIST', '''ALIGNE'''); DBMS_DATAPUMP.METADATA_FILTER(l_dp_handle, 'EXCLUDE_PATH_EXPR', 'IN (''INDEX'', ''SYNONYMS'',''GRANTS'',''STATISTICS'')'); DBMS_DATAPUMP.start_job(l_dp_handle); DBMS_DATAPUMP.WAIT_FOR_JOB(l_dp_handle, v_job_state); DBMS_OUTPUT.PUT_LINE(v_job_state); END;
See you soon,.
Harry -
dbms_datapump - how to ennusre pl/sql only ends when working.
Hello
Call dbms_datapump via pl/sql - look at outpurt directory where the log files and export are created it seems to take a certain time but pl/sql comes in saying all the much earlier.
Uisng 11.2.0.3
Want to pl/sql to display complete only when it is truly comprehensive.
Seems tobe running in background.
This causes.declare -- Local variables here i integer; h1 number; -- Datapump handle dir_name varchar2(30); -- Directory Name v_file_name varchar2(100); v_log_name varchar2(100); v_job_status ku$_Status; -- The status object returned by get_status v_job_state VARCHAR2(4000); v_status ku$_Status1010; v_logs ku$_LogEntry1010; v_row PLS_INTEGER; v_current_sequence_number archive_audit.aa_etl_run_num_seq%type; v_jobState user_datapump_jobs.state%TYPE; begin --execute immediate ('alter tablespace ARCHIVED_PARTITIONS read only'); -- Get last etl_run_num_seq by querying public synonym ARCHIVE_ETL_RUN_NUM_SEQ -- Need check no caching on etl_run_num_seq select last_number - 1 into v_current_sequence_number from ALL_SEQUENCES A WHERE A.SEQUENCE_NAME = 'ETL_RUN_NUM_SEQ'; v_file_name := 'archiveexppre.'||v_current_sequence_number; v_log_name := 'archiveexpprelog.'||v_current_sequence_number; dbms_output.put_line(v_file_name); dbms_output.put_line(v_log_name); -- Create a (user-named) Data Pump job to do a schema export. dir_name := 'DATA_EXPORTS_DIR'; h1 := dbms_datapump.open(operation =>'EXPORT', job_mode =>'TRANSPORTABLE', remote_link => NULL, job_name => 'ARCHIVEEXP10');--||v_current_sequence_number); dbms_datapump.add_file(handle =>h1, filename => v_file_name, directory => dir_name, filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_DUMP_FILE, reusefile => 1); -- value of 1 instructs to overwrite existing file dbms_datapump.add_file(handle =>h1, filename => v_log_name, directory => dir_name, filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE, reusefile => 1); -- value of 1 instructs to overwrite existing file dbms_datapump.metadata_filter( handle => h1, name => 'TABLESPACE_EXPR', VALUE => 'IN(''ARCHIVED_PARTITIONS'')' ); -- --dbms_datapump.metadata_filter(handle =>h1, -- name => 'TABLE_FILTER', -- value => 'BATCH_AUDIT'); -- Start the datapump_job -- -- dbms_datapump.set_parameter(h1, 'TRANSPORTABLE', 'ALWAYS'); dbms_datapump.start_job(h1); begin null; -- dbms_datapump.detach(handle => h1); end; dbms_datapump.wait_for_job(h1,v_jobState); dbms_output.put_line('Job has completed'); exception when others then dbms_datapump.get_status(handle => h1, mask => dbms_datapump.KU$_STATUS_WIP, timeout=> 0, job_state => v_job_state, status => v_job_status); dbms_output.put_line(v_job_state); RAISE_APPLICATION_ERROR(-20010,DBMS_UTILITY.format_error_backtrace); end;
How can I make sure that the work of pl/sql ends only when the work of dbms_daatpump i.e. runs first plan.
Tried to add dbms_datapump.wait_for_job (h1, v_jobState);
but get message job is not attached to this session when adding this.
Deleted Dbms_datapump.detach and now wokrs OK - seems that dbms_datapump.detach + job queue is mutually exclusive?
Thank you
Published by: user5716448 on 28-Sep-2012 06:37
Published by: user5716448 on 28-Sep-2012 06:37
Published by: user5716448 on 28-Sep-2012 06:38
Published by: user5716448 on 28-Sep-2012 06:47
Published by: user5716448 on 28-Sep-2012 06:50user5716448 wrote:
Deleted Dbms_datapump.detach and now wokrs OK - seems that dbms_datapump.detach + job queue is mutually exclusive?
If you want your block to WAIT until the datapump finishes, why loose you? Detach means you are more interested in once work has begun. Remove detach it and keep the wait_for_job you've discovered.
-
dbms_datapump import dblink ORA-39165
Hi all
I try to import a table on a from dblink to a diagram a diagram b but I get ORA-39165 scheme ('A') has not been found. and ORA-39166 object ('ACCOUNT') has not been found. When you try to import b to b it works but oddly always saves an ORA-39166. User B has imp_full_database and permission on two databases:
declare
Number of JobHandle;
JS varchar2 (9); -COMPLETED or STOPPED
q varchar2 (1): = chr (39);
BEGIN / * open a new level of schema import job using a link to default DB * /.
JobHandle: = dbms_datapump.open (operation = > 'IMPORT',)
job_mode = > 'TABLE',
remote_link = > "MRT");
dbms_datapump.add_file (JobHandle,
filename = > "mylog";
Directory = > 'DATA_PUMP_DIR. "
filetype = > dbms_datapump.ku$ _file_type_log_file);
dbms_datapump.metadata_remap (manage = > JobHandle,)
name = > 'REMAP_SCHEMA ',.
old_value = > "A"
value = > 'B');
dbms_datapump.metadata_filter (manage = > JobHandle,)
name = > 'SCHEMA_EXPR ',.
value = > "IN"A","
object_type = > 'TABLE');
dbms_datapump.metadata_filter (manage = > JobHandle,)
name = > 'NAME_LIST;
' value = > '('' COMPTE ''), '
object_type = > 'TABLE');
dbms_datapump.set_parameter (JobHandle,
"TABLE_EXISTS_ACTION."
'REPLACE');
dbms_datapump. START_JOB (JobHandle);
dbms_datapump.wait_for_job (JobHandle, js);
end;
For the life of me I don't understand how can I tell him that the source table is in A diagram. Any help would be greatly appreciated.
Thank you very muchOk. Then you export in job_mode SCHEME and patterns of filter and tables, using metadata filter with SCHEMA_EXPR and INCLUDE_PATH_EXPR.
Using the code you provided, here it is changed:
declare JobHandle number; js varchar2(9); -- COMPLETED or STOPPED q varchar2(1) := chr(39); BEGIN /* open a new schema level import job using a default DB link */ JobHandle := dbms_datapump.open (operation=>'IMPORT', job_mode=>'SCHEMA', remote_link=>'RMT'); dbms_datapump.add_file (JobHandle, filename => 'mylog', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_log_file); --- DBMS_DATAPUMP.metadata_filter (handle=> JobHandle, name=> 'SCHEMA_EXPR',VALUE=> 'IN(''A'')'); dbms_datapump.metadata_filter (handle => JobHandle,name => 'INCLUDE_PATH_EXPR',value => 'IN (''TABLE'')'); -- dbms_datapump.metadata_remap ( handle=>JobHandle,name=> 'REMAP_SCHEMA',old_value=> 'A',value=> 'B'); dbms_datapump.metadata_filter (handle =>JobHandle, name =>'NAME_LIST', value =>'(''ACCOUNT'')',object_type => 'TABLE'); dbms_datapump.set_parameter ( JobHandle,'TABLE_EXISTS_ACTION','REPLACE' ); dbms_datapump.start_job( JobHandle); dbms_datapump.wait_for_job( JobHandle, js); end; /
I tested it with 10.2.0.3 on both sites, and it worked:
-- mylog.log content: Starting "B"."SYS_IMPORT_SCHEMA_03": Estimate in progress using BLOCKS method... Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 64 KB Processing object type SCHEMA_EXPORT/TABLE/TABLE . . imported "B"."ACCOUNT" 1 rows Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT ORA-39083: Object type OBJECT_GRANT failed to create with error: ORA-01749: you may not GRANT/REVOKE privileges to/from yourself Failing sql is: GRANT SELECT ON "B"."ACCOUNT" TO "B" ORA-39166: Object ('ACCOUNT') was not found. Job "B"."SYS_IMPORT_SCHEMA_03" completed with 2 error(s) at 17:35:40
And the table was created to the destination site:
B@local> select * from account; N ---------- 1
If you do not have a direct subsidy that B A.ACCOUNT on the remote site, then you will see this output, but the table is imported anyway:
Processing object type SCHEMA_EXPORT/TABLE/TABLE . . imported "B"."ACCOUNT" 1 rows ORA-39166: Object ('ACCOUNT') was not found.
Kind regards.
Nelson -
DBMS_DATAPUMP parameter problem
Hello
Try to use the aPL/SQL 11g R1 procedure which did a quick export fo a few tables using dbms_datapump which replaces the same output file whenever it is running, the script below. Problem is that it will not overwrite the existing file - I found that there is a parameter REUSE_DUMPFILES, who works with the command of the expdp line but I am unable to be recognized in my script!
I tried the next line using high - and low of breaks 'Y', but it fails on compiling. What I am doing wrong?
dbms_datapump.set_parameter (handle = > h1, name = > 'REUSE_DUMPFILES', value = > 'y');
Main script
CREATE or REPLACE procedure DCH_ERPM.instant_dump
as
NUMBER of H1;
Start
H1: = dbms_datapump.open (operation = > 'EXPORT', job_mode = > 'TABLE', job_name = > ", version = > 'COMPATIBLE');
dbms_datapump.set_parallel (handle = > h1, degree = > 1);
dbms_datapump.set_parameter (handle = > h1, name = > 'KEEP_MASTER', value = > 0);
dbms_datapump.metadata_filter (manage = > h1, name = > 'SCHEMA_EXPR', value = > 'IN ("DCH_ERPM")');
dbms_datapump.metadata_filter (manage = > h1, name = > 'NAME_EXPR', value = > 'IN ("PF00_INDICATORS", "PF01_ANNUALCRIT", "PF02_VALUES")');
dbms_datapump.add_file (handle = > h1, filename = > 'ERPM_quick' | to_char (sysdate, 'YYMMDDHH24MISS') |'.) (DMP", directory = >"DATA_PUMP_DIR", filetype = > 1);
dbms_datapump.set_parameter (handle = > h1, name = > 'INCLUDE_METADATA', value = > 1);
dbms_datapump.set_parameter (handle = > h1, name = > 'DATA_ACCESS_METHOD', value = > "AUTOMATIC").
dbms_datapump.set_parameter (handle = > h1, name = > "ESTIMATION", value = > 'BLOCKS');
dbms_datapump. START_JOB (handle = > h1, skip_current = > 0, abort_step = > 0);
dbms_datapump. Detach (handle = > h1);
end;Hi Steve,.
You may need to call external shell program to remove the existing files of the procedure. Maybe following help.
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:16212348050
Concerning
-
Procedure DBMS_DATAPUMP to function
Hello
I created a procedure that works quite well as follows:
... and I use the following code from PL/SQL to execute, which works very well also.CREATE OR REPLACE PROCEDURE proc_expdp(p_schema_name VARCHAR2, p_table_name VARCHAR2) IS v_handle NUMBER; v_jobname VARCHAR2 (100); v_dirname VARCHAR2 (100); v_filename VARCHAR2 (100); BEGIN v_filename := to_char(sysdate,'YYYYMMDDHH24MISS')||'.DMP'; v_jobname := v_filename||'_EXPDP'; v_dirname := 'DMPDIR'; v_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'TABLE', job_name => v_jobname); dbms_datapump.add_file(handle => v_handle, filename => v_filename, directory => v_dirname, filetype => 1); dbms_datapump.add_file(handle => v_handle, filename => v_filename||'_EXPDP'||'.LOG', directory => v_dirname, filetype => 3); dbms_datapump.metadata_filter (handle => v_handle, name => 'SCHEMA_EXPR', value => 'IN ('||p_schema_name||')'); dbms_datapump.metadata_filter (handle => v_handle, name => 'NAME_EXPR', value => 'IN ('||p_table_name||')'); -- dbms_datapump.data_filter (handle => v_handle, name => 'PARTITION_LIST', value => '''ODS_SLS_ITEM_DETAIL_20090101'', ''ODS_SLS_ITEM_DETAIL_20090102'', more here ''ODS_SLS_ITEM_DETAIL_20090227'', ''ODS_SLS_ITEM_DETAIL_20090228''', table_name => 'ODS_SLS_ITEM_DETAIL', schema_name => 'ODSPROD'); dbms_datapump.start_job(v_handle); dbms_datapump.detach(v_handle); END;
I needed this as a function, so I corrected the following text:BEGIN proc_expdp('''HR''','''DEPARTMENTS'',''EMPLOYEES'''); END;
... and I wouldn't be able to run it with a select statement. Well, this part is the problem. When I try to run as a select statementCREATE OR REPLACE FUNCTION system.func_expdp(p_schema_name VARCHAR2, p_table_name VARCHAR2) RETURN VARCHAR2 IS v_handle NUMBER; v_jobname VARCHAR2 (100); v_dirname VARCHAR2 (100); v_filename VARCHAR2 (100); BEGIN v_filename := to_char(sysdate,'YYYYMMDDHH24MISS')||'.DMP'; v_jobname := v_filename||'_EXPDP'; v_dirname := 'DMPDIR'; v_handle := dbms_datapump.open(operation => 'EXPORT', job_mode => 'TABLE', job_name => v_jobname); dbms_datapump.add_file(handle => v_handle, filename => v_filename, directory => v_dirname, filetype => 1); dbms_datapump.add_file(handle => v_handle, filename => v_filename||'_EXPDP'||'.LOG', directory => v_dirname, filetype => 3); dbms_datapump.metadata_filter (handle => v_handle, name => 'SCHEMA_EXPR', value => 'IN ('||p_schema_name||')'); dbms_datapump.metadata_filter (handle => v_handle, name => 'NAME_EXPR', value => 'IN ('||p_table_name||')'); -- dbms_datapump.data_filter (handle => v_handle, name => 'PARTITION_LIST', value => '''ODS_SLS_ITEM_DETAIL_20090101'', ''ODS_SLS_ITEM_DETAIL_20090102'', more here ''ODS_SLS_ITEM_DETAIL_20090227'', ''ODS_SLS_ITEM_DETAIL_20090228''', table_name => 'ODS_SLS_ITEM_DETAIL', schema_name => 'ODSPROD'); dbms_datapump.start_job(v_handle); dbms_datapump.detach(v_handle); return v_filename; END func_expdp;
I get the following error:select system.func_expdp('''HR''','''DEPARTMENTS'',''EMPLOYEES''') from dual;
What I would do... ?An error was encountered performing the requested operation: 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 "SYSTEM.FUNC_EXPDP", line 4356 ORA-06512: at "SYSTEM.FUNC_EXPDP", line 11 31626. 00000 - "job does not exist" *Cause: An invalid reference to a job which is no longer executing, is no executing on the instance where the operation was attempted, or that does not have a valid Master Table. Refer to any following error messages for clarification. *Action: Start a new job, or attach to an existing job that has a valid Master Table.
Thanks for your time
PS: I use 10g Express Edition. Lately I have created and deleted several datapump jobs, but I think it's irrelevant since my procedure works very well.You cannot use the function inside a SELECT statement because dbms_datapump.open does an implicit validation. However, you can use the function within a pl/sql as block:
declare l_filename varchar2(100); begin l_filename := system.func_expdp('''HR''','''DEPARTMENTS'',''EMPLOYEES''') end; /
Also, please avoid creating all objects in the SYS and SYSTEM schemas.
-
ORA-31626 dbms_datapump running
I wrote some PL/SQL to do nightly exports of my database, but I have been unable to operate. I'm getting an ORA-31626. A search of Metalink has not yield well except a few possible references to the aq_tm_processes and streams_pool_size.
Has anyone else seen elsewhere? My streams_pool_size is 0, but I use the automatic SGA sizing so what I understand pool of watercourses should not be defined more precisely and Oracle will allocate space to the pool shared according to the needs. Code pasted below:
Thank you
< pre >
DECLARE
l_dp_handle NUMBER;
l_last_job_state VARCHAR2 (30): = "UNDEFINED";
l_job_state VARCHAR2 (30): = "UNDEFINED";
l_sts KU$ _STATUS;
v_file_handle UTL_FILE. TYPE_DE_FICHIER;
v_exists BOOLEAN;
v_dbname VARCHAR2 (12);
v_expfile VARCHAR2 (32);
v_explog VARCHAR2 (32);
v_expfile1 VARCHAR2 (32);
v_explog1 VARCHAR2 (32);
v_expfile2 VARCHAR2 (32);
v_explog2 VARCHAR2 (32);
V_LENGTH NUMBER;
v_blocksize NUMBER;
v_jobstate VARCHAR2 (30);
v_jobstatus KU$ _JOBSTATUS;
v_status KU$ _STATUS;
v_scn NUMBER;
BEGIN
SELECT name
IN v_dbname
DATABASE of v$.
v_expfile: = v_dbname | ' _exp.dmp';
v_explog: = v_dbname | ' _exp.log';
v_expfile1: = v_dbname | ' 1_exp.dmp';
v_explog1: = v_dbname | ' 1_exp.log';
v_expfile2: = v_dbname | ' 2_exp.dmp';
v_explog2: = v_dbname | ' 2_exp.log';
DBMS_OUTPUT. ENABLE (1000000);
-Checks if a file exists and if so rename
UTL_FILE. FGETATTR ('DUMP_FILES', v_expfile1, v_exists, v_length, v_blocksize);
IF v_exists
THEN
dbms_output.put_line (' Rename ' | v_expfile1 |' to ' | v_expfile2);
UTL_FILE. FRENAME (src_location = > 'DUMP_FILES', nomfichier_src = > v_expfile1 dest_location = > 'DUMP_FILES', dest_filename = > v_expfile2, overwrite = > TRUE);
dbms_output.put_line (' Rename ' | v_explog1 |' to ' | v_explog2);
UTL_FILE. FRENAME (src_location = > 'DUMP_FILES', nomfichier_src = > v_explog1 dest_location = > 'DUMP_FILES', dest_filename = > v_explog2, overwrite = > TRUE);
dbms_output.put_line ("' renowned files.");
END IF;
-Rename the current file
UTL_FILE. FGETATTR ('DUMP_FILES', v_expfile, v_exists, v_length, v_blocksize);
IF v_exists
THEN
dbms_output.put_line (' Rename ' | v_expfile |' to ' | v_expfile1);
UTL_FILE. FRENAME (src_location = > 'DUMP_FILES', nomfichier_src = > v_expfile dest_location = > 'DUMP_FILES', dest_filename = > v_expfile1, overwrite = > TRUE);
dbms_output.put_line (' Rename ' | v_explog |' to ' | v_explog1);
UTL_FILE. FRENAME (src_location = > 'DUMP_FILES', nomfichier_src = > v_explog dest_location = > 'DUMP_FILES', dest_filename = > v_explog1, overwrite = > TRUE);
dbms_output.put_line ("' renowned files.");
END IF;
-Export full Begin
dbms_output.put_line (' ' start export ');
-Get the current database YVERT
SELECT current_scn
IN v_scn
DATABASE of v$.
l_dp_handle: = dbms_datapump.open (operation = > 'EXPORT', job_mode = > 'FULL', remote_link = > NULL, job_name = > "NIGHTLY_EXPORT", version = > 'LATER');
dbms_datapump.add_file (handle = > l_dp_handle, filename = > v_expfile, directory = > 'DUMP_FILES', filetype = > DBMS_DATAPUMP.) KU$ _FILE_TYPE_DUMP_FILE);
dbms_datapump.add_file (handle = > l_dp_handle, filename = > v_explog, directory = > 'DUMP_FILES', filetype = > DBMS_DATAPUMP.) KU$ _FILE_TYPE_LOG_FILE);
dbms_datapump.set_parameter (handle = > l_dp_handle, name = > 'FLASHBACK_SCN', value = > v_scn); -Even running consistent traditional export mode
dbms_datapump. START_JOB (l_dp_handle);
-Start loop to determine whether the task is complete
v_jobstate: = "UNDEFINED";
WHILE (v_jobstate! = 'COMPLETE') and (v_jobstate! = "STOPPED")
LOOP
DBMS_DATAPUMP. GET_STATUS)
manage = > l_dp_handle,
mask = > 15,-DBMS_DATAPUMP.ku$ _status_job_error + DBMS_DATAPUMP.ku$ _status_job_stats + DBMS_DATAPUMP.ku$ _status_wip
Timeout = > NULL,
job_state = > v_jobstate,
State = > v_status
);
v_jobstatus: = v_status.job_status;
END LOOP;
dbms_output.put_line (' export completed with status: ' | v_jobstate);
dbms_datapump. Detach (l_dp_handle);
END;
< / pre >I don't say that the size of my pool is just, but it's what I have:
shared_pool_size = 400 m
STREAMS_POOL_SIZE = 13 mSince this failure on the command open, I wonder if you already have a job that is opened with the same name. While I was trying to get your script to work, I removed the job_name = "NIGHTLY_EXPORT" and assign
job_name-online null,
This creates just a job name that is not already in use.
Dean
-
I have oracle 10g installed on my system.
I created an expdir file and add the oracle directory.
For datapump, I ran this:
declare
number of H1;
Start
H1: = dbms_datapump.open ('EXPORT', 'SCHEMA');
dbms_datapump.add_file (h1, 'exp1.dmp', 'expdir');
dbms_datapump.metadata_filter (h1, 'schema_expr', '= "hr" ');
dbms_datapump.set_parallel (h1, 4);
dbms_datapump. START_JOB (H1);
dbms_datapump. Detach (H1);
end;
/
and got this error:
ERROR on line 1:
ORA-39001: invalid argument value
ORA-06512: at "SYS." DBMS_SYS_ERROR', line 79
ORA-06512: at "SYS." DBMS_DATAPUMP', line 2926
ORA-06512: at "SYS." DBMS_DATAPUMP', line 3162
ORA-06512: at line 5
Any help-Robette,
Use this example and replace by your directory and schemaname and jobname.
SET SERVEROUTPUT ON SIZE 1000000 DECLARE l_dp_handle NUMBER; l_last_job_state VARCHAR2 (30) := 'UNDEFINED'; l_job_state VARCHAR2 (30) := 'UNDEFINED'; l_sts ku$_status; BEGIN l_dp_handle := DBMS_DATAPUMP.open (operation => 'EXPORT', job_mode => 'SCHEMA', remote_link => NULL, job_name => 'RET_EXPORT', version => 'LATEST' ); DBMS_DATAPUMP.add_file (handle => l_dp_handle, filename => 'myexport.dmp', directory => 'EXPORT_DIR' ); DBMS_DATAPUMP.add_file (handle => l_dp_handle, filename => 'myexport.log', directory => 'EXPORT_DIR', filetype => DBMS_DATAPUMP.ku$_file_type_log_file ); DBMS_DATAPUMP.metadata_filter (handle => l_dp_handle, name => 'SCHEMA_EXPR', VALUE => '= ''MYSCHEMA''' ); DBMS_DATAPUMP.start_job (l_dp_handle); DBMS_DATAPUMP.detach (l_dp_handle); END; /
Concerning
-
Export of DataPump API - number of rows exported using
Hello
I'm working on the procedure to export data in the table before deleting the partition. It will be run by the Scheduler of the data, that's why I want to run the datapump job using the API.
I wonder, if it is possible to get the number of rows exported. I would compare with the number of rows in a partition before you delete the partition.
Thank you
Krystian
Hello
Don't know exactly how you want the number of rows per partition that have been exported, but here are a few ideas:
1. create a log file by using 'add_file ':
-Add a log file
dbms_datapump.add_file (h, ' DEPTJOB.log ', a', NULL,)
dbms_datapump.Ku$ _file_type_log_file);
It is also in my example included below. Here is the content after the DEPTJOB.log workload (situated in Oracle Directory object would be "in my example):
$ cat /tmp/DEPTJOB.log
Departure 'SCOTT '. "" DEPTJOB ":
Object type TABLE_EXPORT/TABLE/TABLE processing
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . "exported"SCOTT" DEPT': 'SYS_P1581' 5,929 KB 2 lines
. . "exported"SCOTT" DEPT': 'SYS_P1582' 5,914 KB 1 lines
. . "exported"SCOTT" DEPT': 'SYS_P1583' 5,906 KB 1 lines
Table main 'SCOTT '. "' DEPTJOB ' properly load/unloaded
******************************************************************************
Empty the files together for SCOTT. DEPTJOB is:
/tmp/Dept.dmp
Job 'SCOTT '. "" DEPTJOB "managed to 00:00
You can then review or extract the information from the log file.
2. save the master table and the query for the busy lines.
Use the parameter "KEEP_MASTER":
-Keep the main table to be deleted after employment ends
dbms_datapump.set_parameter(h,'KEEP_MASTER',1);
Here's my example, the request to the main table is at the end.
$ sqlplus scott/tiger @deptapi
SQL * more: version 12.2.0.0.2 Beta on Fri Jan 22 12:55:52 2016
Copyright (c) 1982, 2015, Oracle. All rights reserved.
Last successful login time: Friday, January 22, 2016 12:55:05-08:00
Connected to:
Database Oracle 12 c Enterprise Edition Release 12.2.0.0.2 - 64-bit Beta
With the options of partitioning, OLAP, advanced analytics and Real Application Testing
Connected.
SQL > SET FEEDBACK 1
SQL > SET 10 NUMLARGEUR
SQL > SET LINESIZE 2000
SQL > SET TRIMSPOOL ON
SQL > SET TAB OFF
SQL > SET PAGESIZE 100
SQL > SET SERVEROUTPUT ON
SQL >
SQL > Rem save on the old table of scott.dept
SQL > dept and rename it dept_old.
Renamed table.
SQL >
SQL > Rem re-create it with partitions
SQL > CREATE TABLE dept (deptno NUMBER varchar (14) dname, loc varchar (13)) PARTITION INTO 3 PARTITIONS HASH (deptno)
2.
Table created.
SQL >
SQL > Rem fill the dept table
SQL > insert into dept select * from dept_old;
4 lines were created.
SQL >
SQL > Rem now create datapump job export SCOTT. DEPT. using the API
SQL > DECLARE
2: NUMBER; -Handle Datapump
3 jobState VARCHAR2 (30); -To keep track of job status
4 ind NUMBER; -Index of the loop
5 the ku$ _LogEntry; -For error messages and work in PROGRESS
6 js ku$ _JobStatus; -The State of the work of get_status
7 jd ku$ _JobDesc; -The get_status job description
8 m ku$ _Status; -The status returned by get_status object
9 sql_stmt VARCHAR2 (1024);
nom_partition 10-VARCHAR2 (50);
11 rows_completed NUMBER;
12
BEGIN 13
14-
15 run the Installer based on the operation to perform.
16-
17 h: = dbms_datapump.open ('EXPORT', 'TABLE', NULL, 'DEPTJOB', NULL);
18 dbms_datapump.add_file (h, 'dept.dmp', 'd', NULL,
dbms_datapump.Ku$ _file_type_dump_file 19, 1);
20
21 --- Add a logfile
22 dbms_datapump.add_file (h, ' DEPTJOB.log ', a', NULL,)
23 dbms_datapump.ku$ _file_type_log_file);
24
25 dbms_datapump.metadata_filter (h, 'SCHEMA_EXPR', ' IN ("SCOTT") ");
26 dbms_datapump.metadata_filter (h, 'NAME_LIST', "'DEPT"');
27
28
29-
30 start work.
31-
32 dbms_datapump.set_parameter (h, 'SILENT', 'banner');
33
34 -keep the main table to be deleted after employment ends
35 dbms_datapump.set_parameter(h,'KEEP_MASTER',1);
36
37 dbms_datapump.start_job (h);
38
39-
40 - run to grabbing the output of the job and write in the output log.
41-
42 jobState: = "UNDEFINED";
43 WHILE (jobState! = "COMPLETED") AND (jobState! = "STOPPED")
44 LOOP
45 dbms_datapump.get_status (h,
dbms_datapump.Ku$ _status_job_error 46.
dbms_datapump.Ku$ _status_wip 47, -1, jobState, m);
48
49 --
50. If we received messages WIP or error for the work, display them.
51 --
52 IF (BITAND(sts.mask,dbms_datapump.ku$_status_wip)! = 0)
53 THEN
54: = sts.wip;
55 ON THE OTHER
56 IF (bitand(sts.mask,dbms_datapump.ku$_status_job_error)! = 0)
57 THEN
58: = sts.error;
59 ON THE OTHER
the 60: = NULL;
61 END IF;
62 END IF;
63
64 the IS NOT NULL IF
65 THEN
66 ind: = the. FIRST;
67 then AS ind IS NOT NULL
68 LOOP
69 dbms_output.put_line ((ind). LogText);
70 ind: = the. Next (IND);
LOOP END 71;
72 END IF;
73 END LOOP;
74
75-
76 - release work.
77-
78 dbms_datapump.detach (h);
79
80-
81. all exceptions that spread at this point will be captured.
82 - the details are extracted from get_status and displayed.
83-
EXCEPTION OF 84
85, SO THAN OTHERS THEN
BEGIN 86
87 dbms_datapump.get_status (h,
dbms_datapump.Ku$ _status_job_error, 0-88,.
89 jobState, sts);
90 IF (BITAND(sts.mask,dbms_datapump.ku$_status_job_error)! = 0)
91 THEN
the 92: = sts.error;
93 the IS NOT NULL IF
94 THEN
95 ind: = the. FIRST;
96 although ind IS NOT NULL
LOOP OF 97
98 dbms_output.put_line ((ind). LogText);
99 ind: = the. Next (IND);
100 END LOOP;
101 END IF;
102 END IF;
103
BEGIN 104
105 DBMS_DATAPUMP. STOP_JOB (m, 1, 0, 0);
EXCEPTION OF 106
107. WHEN OTHER NULL THEN;
END 108;
109
110 EXCEPTION
111, SO THAN OTHERS THEN
112 dbms_output.put_line ('ORA-00000: an unexpected exception during ' |)
113 ' Manager of exceptions. ' ||
114 ' sqlcode = ' | TO_CHAR (SQLCODE));
END 115;
END 116;
117.
Departure 'SCOTT '. "" DEPTJOB ":
Object type TABLE_EXPORT/TABLE/TABLE processing
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . "exported"SCOTT" DEPT': 'SYS_P1581' 5,929 KB 2 lines
. . "exported"SCOTT" DEPT': 'SYS_P1582' 5,914 KB 1 lines
. . "exported"SCOTT" DEPT': 'SYS_P1583' 5,906 KB 1 lines
Table main 'SCOTT '. "' DEPTJOB ' properly load/unloaded
******************************************************************************
Empty the files together for SCOTT. DEPTJOB is:
/tmp/Dept.dmp
Job 'SCOTT '. "" DEPTJOB "managed to 00:00
PL/SQL procedure successfully completed.
SQL >
SQL > table main query Rem for number of lines completed
SQL > column nom_partition format a10
SQL > format 9999 column lines
SQL > SELECT nom_partition, COMPLETED_ROWS FROM SCOTT . DEPTJOB WHERE BASE_OBJECT_NAME = "DEPT";
PARTITION_ COMPLETED_ROWS
---------- --------------
SYS_P1581 2
SYS_P1583 1
SYS_P1582 1
3 selected lines.
SQL >
SQL > "EXIT";
3. you might even extract information of the call from the command line:
$ sqlplus scott/tiger @deptapi.sql | grep 'exported ' | AWK ' {print "Table:" $4, 'charge' $7, $8} '
Table: 'SCOTT '. "" DEPT ":"SYS_P1581"loaded 2 rows
Table: 'SCOTT '. "' DEPT ': 'SYS_P1583' loaded 1 lines
Table: 'SCOTT '. "' DEPT ': 'SYS_P1582' loaded 1 lines
-
How to get information of parameters of a procedure in my schema?
Mr President.
My oracle database is ee 11g.
My schema name is ash.
I have a procedure in it. How to get its parameter information.
the code of procedure is
create or replace PROCEDURE "EXPORT_DB_PROC" AS h1 NUMBER; dt VARCHAR2 (20); myschema VARCHAR2(32):='ash'; BEGIN SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') INTO dt FROM DUAL; h1 := DBMS_DATAPUMP.OPEN (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => myschema||'_EXP_' || dt, VERSION => 'COMPATIBLE' ); DBMS_DATAPUMP.set_parallel (handle => h1, DEGREE => 1); DBMS_DATAPUMP.add_file (handle => h1, filename => myschema||'_EXP.LOG', DIRECTORY => 'ADMIN_DIR', filetype => 3 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'KEEP_MASTER', VALUE => 0 ); DBMS_DATAPUMP.metadata_filter (handle => h1, NAME => myschema||'_EXPR', VALUE => 'IN('''||myschema||''')' ); DBMS_DATAPUMP.add_file (handle => h1, filename => myschema||'_EXP_' || dt || '.DMP', DIRECTORY => 'DATA_PUMP_DIR', filetype => 1 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'INCLUDE_METADATA', VALUE => 1 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'DATA_ACCESS_METHOD', VALUE => 'AUTOMATIC' ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'ESTIMATE', VALUE => 'BLOCKS' ); DBMS_DATAPUMP.start_job (handle => h1, skip_current => 0, abort_step => 0); DBMS_DATAPUMP.detach (handle => h1); END; /
How to get information on the parameters (names and types etc.)
Concerning
Hello
SQL > create or replace procedure proc (tes1 number) start the null; end;
2.Created procedure.
SQL > desc proc
Proc PROCEDURE
Name of default input/output argument type?
------------------------------ ----------------------- ------ --------
TES1 NUMBER INAre you referring to the right parameters of proc right?
Think simple
-Thank you
Pavan Kumar N
-
Mr President.
Any body give me advice step by step that how can I use my pl/sql below procedure to take the small schema oracle backup with a touch of the adf.
DECLARE h1 NUMBER; dt VARCHAR2 (20); myschema VARCHAR2(32):='SCOTT'; BEGIN SELECT TO_CHAR (SYSDATE, 'YYYYMMDD') INTO dt FROM DUAL; h1 := DBMS_DATAPUMP.OPEN (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => myschema||'_EXP_' || dt, VERSION => 'COMPATIBLE' ); DBMS_DATAPUMP.set_parallel (handle => h1, DEGREE => 1); DBMS_DATAPUMP.add_file (handle => h1, filename => myschema||'_EXP.LOG', DIRECTORY => 'ADMIN_DIR', filetype => 3 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'KEEP_MASTER', VALUE => 0 ); DBMS_DATAPUMP.metadata_filter (handle => h1, NAME => myschema||'_EXPR', VALUE => 'IN('''||myschema||''')' ); DBMS_DATAPUMP.add_file (handle => h1, filename => myschema||'_EXP_' || dt || '.DMP', DIRECTORY => 'DATA_PUMP_DIR', filetype => 1 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'INCLUDE_METADATA', VALUE => 1 ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'DATA_ACCESS_METHOD', VALUE => 'AUTOMATIC' ); DBMS_DATAPUMP.set_parameter (handle => h1, NAME => 'ESTIMATE', VALUE => 'BLOCKS' ); DBMS_DATAPUMP.start_job (handle => h1, skip_current => 0, abort_step => 0); DBMS_DATAPUMP.detach (handle => h1); END; /
Concerning
Hello world!
It's the simple code to call an appModule procedure
public void callStoreprocedureWithoutInput() { String stmt = "BEGIN\n" + " \"dbBackup\"();\n" + "--rollback; \n" + "END;"; PreparedStatement st = null; try { st = getDBTransaction().createPreparedStatement(stmt, 0); st.executeUpdate(); st.close(); } catch (Exception e) { e.printStackTrace(); } }
Concerning
-
Works Datapump inside the SQL worksheet...
Hi all
"running the following code inside the spreadsheet and he just spits ' anonymous block completed.
*****************************
Set scan off
Set serveroutput on
escape game off
whenever sqlerror exit
DECLARE
number of H1;
errorvarchar varchar2 (100): = "ERROR";
tryGetStatus number: = 0;
Start
H1: = dbms_datapump.open (operation = > 'IMPORT', job_mode = > job_name 'FULL' = > 'IMPORT_JOB_SQLDEV_73', version = > 'COMPATIBLE');
tryGetStatus: = 1;
dbms_datapump.set_parallel (handle = > h1, degree = > 1);
dbms_datapump.add_file (handle = > h1, filename = > 'IMPORTtest2.LOG', directory = > 'DATA_PUMP_DIR', filetype = > 3);
dbms_datapump.set_parameter (handle = > h1, name = > 'KEEP_MASTER', value = > 0);
dbms_datapump.add_file (handle = > h1, filename = > ' ORAEU_COPIED.) (DMP", directory = >"DATA_PUMP_DIR", filetype = > 1);
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\APT_SYS_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/APT_SYS_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\APT_SYS_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/APT_SYS_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_MART_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_MART_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_MART_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_MART_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > UPPER ('C:\ORACLE\ORADATA\ORCL/DATA_STORE_DATA01.) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_STORE_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_STORE_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_STORE_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\RNET2_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/RNET2_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\RNET2_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/RNET2_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_AMA_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_AMA_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATA_AMA_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATA_AMA_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATASERVICES_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATASERVICES_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\DATASERVICES_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/DATASERVICES_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\ARC_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/ARC_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\MCSS_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/MCSS_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\MCSS_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/MCSS_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\IPAS_DATA01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/IPAS_DATA01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\IPAS_IDX01.)) DBF'), value = > SUPERIOR ('/ rdsdbdata/db/ORAEU_A/file/IPAS_IDX01.) DBF'));
dbms_datapump.metadata_remap (manage = > h1, name = > 'REMAP_DATAFILE', old_value = > SUPERIOR ('C:\ORACLE\ORADATA\ORCL\PFIZERCMS_DATA01.)) DBF "), value = >"
dbms_datapump.set_parameter (handle = > h1, name = > 'INCLUDE_METADATA', value = > 1);
dbms_datapump.set_parameter (handle = > h1, name = > 'DATA_ACCESS_METHOD', value = > "AUTOMATIC").
dbms_datapump.set_parameter (handle = > h1, name = > 'REUSE_DATAFILES', value = > 0);
dbms_datapump.set_parameter (handle = > h1, name = > 'TABLE_EXISTS_ACTION', value = > 'REPLACE');
dbms_datapump.set_parameter (handle = > h1, name = > 'SKIP_UNUSABLE_INDEXES', value = > 0);
dbms_datapump. START_JOB (handle = > h1, skip_current = > 0, abort_step = > 0);
dbms_datapump. Detach (handle = > h1);
errorvarchar: = "NO_ERROR"
EXCEPTION
WHILE OTHERS THEN
BEGIN
IF ((errorvarchar = ' ERROR') AND (tryGetStatus = 1)) THEN
DBMS_DATAPUMP. Detach (H1);
END IF;
EXCEPTION
WHILE OTHERS THEN
NULL;
END;
LIFT;
END;
/
*****************
all entries are appreciated
Thank you
Please let me know if you see a code problem
What is your question has to do with Sql Developer?
Unless you can connect you must mark ANSWERED thread and repost it in Sql and Pl/Sql forum
the Japan Government says:
Hi Jeff
I expect that it runs the import at least.
Get this error now on line 66:
EXCEPTION
WHILE OTHERS THEN
BEGIN
IF ((errorvarchar = ' ERROR') AND (tryGetStatus = 1)) THEN
DBMS_DATAPUMP. Detach (H1);
END IF;
EXCEPTION---> line 66
WHILE OTHERS THEN
NULL;
END;
When you repost you should post the EXACT code you use. The code you posted is NOT valid: you must also REMOVE the WHEN of OTHER or you can expect everyone to book you to INTENTIONALLY HIDE any exceptions that occur. Why do you NOT want to know if Oracle finds problems in your code? That makes NO sense at all.
IF ((errorvarchar = ' ERROR') AND (tryGetStatus = 1)) THEN
There is NO SPACE after the "and" what is garbage just as far as Oracle are concerned.
Either you have posted an incorrect code or your code has syntax errors and will not compile or run anyway.
I suggest that correct you your syntax errors before reposting in the Sql forum. If you have pain to find their delete ALL unnecessary code to reduce the problem to the example as SIMPLE as possible, until you find the code causing errors.
-
help required Oracle export command
Hello gurus
I need to export data from table MBE under certain conditions as below
SELECT MBE.*
OF MBE,.
MSI
WHERE MBE.ID = MSI.ID
AND MSI.NAME = 'MOS '.
How can I achieve this?
exp username/password@schemaname.
tables = MBE query =------"WHERE EXISTS\ (SELECT NULL FROM MSI WHERE MSI.ID = \ MBE.ID AND MSI.NAME = 'MOS' \) \) \' file = MV.dmp log = exp.log
will it work?Please answer
s
I have a table simple import/export api writern using DBMS_DATAPUMP. I hope this helps.
create or replace procedure export_table ( pOwner in varchar2, pTableName in varchar2, pDirectory in varchar2, pFilterStr in varchar2 ) is lDPJobName varchar2(100); lFileName varchar2(100); lJobState varchar2(50) := 'EXECUTING'; lHandle number; lStatus ku$_Status1010; begin lDPJobName := 'TABLE_EXPORT_' || to_char(sysdate, 'YYYYMMDDHH24MISS'); lFileName := upper(pTableName) || '_' || to_char(sysdate, 'YYYYMMDDHH24MISS'); lHandle := dbms_datapump.open('EXPORT', 'TABLE', job_name => lDPJobName); dbms_datapump.add_file (handle => lHandle, filename => lFileName, directory => pDirectory, filetype => dbms_datapump.ku$_file_type_dump_file); dbms_datapump.add_file (handle => lHandle, filename => lFileName, directory => pDirectory, filetype => dbms_datapump.ku$_file_type_log_file); dbms_datapump.set_parameter (handle => lHandle, name => 'KEEP_MASTER', value => 0); dbms_datapump.set_parameter (handle => lHandle, name => 'INCLUDE_METADATA', value => 1); dbms_datapump.metadata_filter (handle => lHandle, name => 'SCHEMA_EXPR', value => '= ''' || upper(trim(pOwner)) || ''''); dbms_datapump.metadata_filter (handle => lHandle, name => 'NAME_EXPR', value => '= ''' || upper(trim(pTableName)) || ''''); dbms_datapump.data_filter (handle => lHandle, name => 'SUBQUERY', value => pFilterStr, table_name => pTableName, schema_name => pOwner); dbms_datapump.start_job (handle => lHandle); dbms_datapump.wait_for_job (handle => lHandle, job_state => lJobState); if trim(upper(lJobState)) = 'STOPPED' then raise_application_error(-20001, 'Job returned status as STOPPED'); else dbms_datapump.detach(handle => lHandle); end if; lHandle := null; end; / show err create or replace procedure import_table ( pDirName in varchar2 , pDmpFileName in varchar2 ) is lHandle integer; lDPJobName VARCHAR2(100); lJobState varchar2(50) := 'EXECUTING'; begin lDPJobName := 'TABLE_EXPORT_' || to_char(sysdate, 'YYYYMMDDHH24MISS'); lHandle := dbms_datapump.open(operation => 'IMPORT', job_mode => 'TABLE', remote_link => '', job_name => lDPJobName); dbms_datapump.add_file (handle => lHandle, filename => pDmpFileName, directory => pDirName, filetype => dbms_datapump.ku$_file_type_dump_file); dbms_datapump.add_file (handle => lHandle, filename => pDmpFileName || '_IMP', directory => pDirName, filetype => dbms_datapump.ku$_file_type_log_file); dbms_datapump.set_parameter (handle => lHandle, name => 'TABLE_EXISTS_ACTION', value => 'APPEND'); dbms_datapump.start_job (handle => lHandle); if trim(upper(lJobState)) = 'STOPPED' then raise_application_error(-20001, 'Job returned status as STOPPED'); else dbms_datapump.detach(handle => lHandle); end if; lHandle := null; end; / show err
His executed like this. For example, I use a TEMP table.
SQL> create table temp as select * from all_objects 2 / Table created. SQL> begin 2 export_table 3 ( 4 'KARTHICK', 5 'TEMP', 6 'DP_KAR_DIR', 7 'WHERE OBJECT_NAME IN (SELECT OBJECT_NAME FROM ALL_OBJECTS WHERE OWNER = ''KARTHICK'')' 8 ); 9 end; 10 / PL/SQL procedure successfully completed. SQL> drop table temp purge; Table dropped. SQL> begin 2 import_table 3 ( 4 'DP_KAR_DIR' 5 , 'TEMP_20140502034806.dmp' 6 ); 7 end; 8 / PL/SQL procedure successfully completed. SQL> select count(*) from temp; COUNT(*) ---------- 200302
Here are the details of the journal
Export log... arttvt04% cat TEMP_20140502034806.log Starting "KARTHICK"."TABLE_EXPORT_20140502034806": Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 23 MB Processing object type TABLE_EXPORT/TABLE/TABLE . . exported "KARTHICK"."TEMP" 18.41 MB 200302 rows Master table "KARTHICK"."TABLE_EXPORT_20140502034806" successfully loaded/unloaded ****************************************************************************** Dump file set for KARTHICK.TABLE_EXPORT_20140502034806 is: /home/arbor/karthick/TEMP_20140502034806.dmp Job "KARTHICK"."TABLE_EXPORT_20140502034806" successfully completed at 03:48:16 Import log... arttvt04% cat TEMP_20140502034806.dmp_IMP Master table "KARTHICK"."TABLE_EXPORT_20140502034956" successfully loaded/unloaded Starting "KARTHICK"."TABLE_EXPORT_20140502034956": Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/TABLE_DATA . . imported "KARTHICK"."TEMP" 18.41 MB 200302 rows Job "KARTHICK"."TABLE_EXPORT_20140502034956" successfully completed at 03:50:00 arttvt04%
Maybe you are looking for
-
Apple Mail unable to answer or close windows
Whenever I try to reply (or reply to all) of any email through the mail app, a new empty message window opens that I can type in but all the buttons (send, attach etc.) are grayed out and I can't close the window without restarting the mail app has m
-
Extension of the memory for S1800-514
Modules that I can use to upgrade (now 2 * 128MB)?My s1800 is very slow and I want to buy second hand models event. but don't know which ones I can use if they are not (too expensive) ToshibaThank you
-
P70 A unable to browse the Wi Fi
Hi all I am unable to navigate or use applications such as FB, Whatsapp etc. When you are connected to my wifi homw. However, my G mail and official e-mail work fine. Help, please
-
I had a false alarm microsoft virus/troj or something on the computer. Scanned with Norton and the virus has been removed, but now whenever I click on most of the applications: itunes, word, excell - it gives me the error-application not found. I c
-
Windows 7 problem screen connect
My user account page has only 2 accounts, my own and a guest. Until recently, he worked as expected. However this week at the start of Windows 7 Edition family premium, I don't see my account. If I click on change user, then I have a choice of 2 icon