Issue creating data pump export job from sqldeveloper - oracle

I am trying to create data pump export using oracle sql developer wizard below are the grants provided to the user from which I am trying to setup data pump export
grant create session, create table, create procedure, exp_full_database, imp_full_database to TESTE;
grant read, write on directory DOCUMENTS to TESTE;
grant read, write on directory DATA_PUMP_DIR to TESTE;
but after completing wizard i get below error
...
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
dbms_output.put_line('REMOVE FINAL TRACE TEXT');
Raise;
END;
Error report -
ORA-31626: job does not exist
ORA-06512: at line 77
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing,
is not 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.
here is the plsql code generated by wizard at the end
set scan off
set serveroutput on
set escape off
whenever sqlerror exit
DECLARE
h1 number;
errorvarchar varchar2(100):= 'ERROR';
tryGetStatus number := 0;
begin
h1 := dbms_datapump.open (operation => 'EXPORT', job_mode => 'SCHEMA', job_name => 'EXPORT_JOB_SQLDEV_944', version => 'COMPATIBLE');
tryGetStatus := 1;
dbms_datapump.set_parallel(handle => h1, degree => 1);
dbms_datapump.add_file(handle => h1, filename => 'EXPDAT-'||to_char(sysdate,'yyyy-mm-dd-hh24_mi_ss')||'.LOG', directory => 'DATA_PUMP_DIR', filetype => 3);
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 1);
dbms_datapump.metadata_filter(handle => h1, name => 'SCHEMA_EXPR', value => 'IN(''MERCHANDISER'')');
dbms_datapump.add_file(handle => h1, filename => 'EXPDAT%U-'||to_char(sysdate,'yyyy-mm-dd-hh24_mi_ss')||'.DMP', directory => 'DATA_PUMP_DIR', filesize => '100M', 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);
errorvarchar := 'NO_ERROR';
EXCEPTION
WHEN OTHERS THEN
BEGIN
IF ((errorvarchar = 'ERROR')AND(tryGetStatus=1)) THEN
DBMS_DATAPUMP.DETACH(h1);
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
RAISE;
END;
/
I have also tried below command in bash
expdp TESTE/TESTEr#localhost schemas=TESTE directory=documents dumpfile=test.dmp logfile=test.log
and got below error
Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
ORA-31626: job does not exist
ORA-31637: cannot create job SYS_EXPORT_SCHEMA_06 for user MERCHANDISER
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT_INT", line 798
ORA-06550: line 1, column 7:
PLS-00331: illegal reference to SYS.SYS
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
any idea what is causing issue

Related

Procedure to move oracledb export to s3 bucket fails when ran in a job

Job fails with:
ORA-29481: Implicit results cannot be returned to client.
ORA-06512: at "SYS.DBMS_SQL", line 2832
ORA-06512: at "SYS.DBMS_SQL", line 2826
ORA-06512: at "owner.SEND_TO_S3", line 8
ORA-06512: at line 1
I can run the procedure manually(BEGIN SEND_TO_S3; END;) without errors and the db exports
show up in the s3 bucket.
****Oracle Job
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'SEND_EXP_TO_S3_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN SEND_TO_S3; END;',
start_date => SYSTIMESTAMP,
enabled => TRUE,
repeat_interval => 'freq=weekly; byday=mon; byhour=20; byminute=40; bysecond=0;');
END;
****Oracle procedure
(If there some other way than to use a refcursor that might solve this issue as well)
CREATE OR REPLACE PROCEDURE send_to_s3
AS
rc sys_refcursor;
BEGIN
open rc for
SELECT
rdsadmin.rdsadmin_s3_tasks.upload_to_s3(
p_bucket_name => 'bucket/name',
p_prefix => 'EXP',
p_s3_prefix => '',
p_directory_name => 'DATA_PUMP_DIR') `your text`
AS TASK_ID FROM DUAL;
DBMS_SQL.RETURN_RESULT(rc);
END send_to_s3;
****The oracle error points to an outdated client but I have the latest client and I'm
not sure the scheduler uses a client.
Is there a way to get this job running correctly?

Oracle Datapump API - APPEND

The following tries to APPEND data to the CLASS table from a dmp that contains several hundred records for that table. There is 1 record already in database and that record also exists in the .dmp. The job completes but no data is appended.
If i switch the parameter to TRUNCATE, the single value is removed and replacedw ith the content of the .dmp i.e .works correctly.
Can anyone tell me what's wrong with this proc that's causing APPEND to fail?
The documentation doesn't seem to offer much beyond a reference to metadata (https://docs.oracle.com/database/121/ARPLS/d_datpmp.htm#ARPLS66059)... i have tried removing the metadata filter included in the code below, but with no +ve result.
Thanks
create or replace procedure import_backup (in_file_name in varchar2,
in_job_name in varchar2,
in_export_filename in varchar2)
is
l_dp_handle number;
l_status varchar2(200); -- Data Pump Status
l_file_name varchar2(100) := nvl(in_file_name,'IMPORTBACKUP');
l_job_name varchar2(100) := nvl(in_job_name,'IMPORTBACKUP20');
l_ipaddress VARCHAR2(20);
l_time VARCHAR2(20);
PROCEDURE_NAME VARCHAR2(30) := 'export_backup';
begin
select PARAM_VALUE
into l_ipaddress
from PARAMETER
where PARAM_NAME = 'DATABASE_SERVER';
select to_char(sysdate, 'YYYYMMDDHHMISS')
into l_time
from dual;
--Log_Message(PROCEDURE_NAME,'Starting with in_file_name: ' || l_file_name || ' and in_job_name: ' || l_job_name);
-- Open a table export job.
l_dp_handle := dbms_datapump.open(operation => 'IMPORT',
job_mode => 'TABLE',
remote_link => NULL,
job_name => l_job_name,
version => 'LATEST');
-- Specify the dump file name and directory object name.
dbms_datapump.add_file(handle => l_dp_handle,
filename => in_export_filename,
directory => 'EXPORT_DIR');
--Specify Truncate mode (to remove table contents and replace with file's contents
DBMS_DATAPUMP.SET_PARAMETER (
handle => l_dp_handle,
name => 'TABLE_EXISTS_ACTION',
value => 'APPEND' );
-- Specify the log file name and directory object name.
dbms_datapump.add_file(
handle => l_dp_handle,
filename => in_export_filename || l_time ||'expdp_XYZ.log',
directory => 'EXPORT_DIR',
filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
-- Specify the table to be imported, filtering the schema and table.
dbms_datapump.metadata_filter(handle => l_dp_handle,
name => 'NAME_EXPR',
value => 'IN (''CLASS'')',
object_type => 'TABLE');
-- Exclude table stats
dbms_datapump.metadata_filter(handle => l_dp_handle,
name => 'EXCLUDE_PATH_EXPR',
value => 'IN (''STATISTICS'')');
dbms_datapump.start_job(l_dp_handle);
-- Wait for job
dbms_datapump.wait_for_job(handle => l_dp_handle,job_state => l_status );
dbms_output.put_line( l_status );
--Log_Message(PROCEDURE_NAME,'Completed DataPump Job');
-- Job will continue running the background until it completes or errors
--dbms_datapump.detach(l_dp_handle);
exception
when others then
--Log_Message(PROCEDURE_NAME,'Datapump job failed');
begin
dbms_datapump.detach(l_dp_handle);
execute immediate 'Drop table ' ||l_job_name ;
end;
end import_backup;
Have attempted using 1 record in exiting table and using APPEND - no results
Have attemped using 1 record in exiting table and using using TRUNCATE - the 1 record is deleted and replaced with the content of the dmp's CLASS table

Data Pump import fails with "job does not exist"

Can anyone help with this problem? I'm trying to use datapump to load a dump file created but whenever I try, I get the following code:
DECLARE
hdnl NUMBER;
status VARCHAR2(20);
BEGIN
hdnl := dbms_datapump.open (operation => 'IMPORT', job_mode => 'TABLE', version => 'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'import.log', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
DBMS_DATAPUMP.ADD_FILE(handle => hdnl, filename => 'latest.dmp', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.START_JOB(handle => hdnl);
DBMS_DATAPUMP.WAIT_FOR_JOB(hdnl,status);
end;
/
I'm getting this error:
Error report -
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 1852
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6793
ORA-06512: at line 5
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing,
is not 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.
Any idea?
Regards

Oracle scheduler error: Security Group ID (your workspace identity) is invalid

I am trying to create oracle scheduler job (send mail) by pl/sql process (job is created on button click). It create job successfully but job always finish with error:
"ORA-20001: Security Group ID (your workspace identity) is invalid. ORA-06512: at "APEX_050100.WWV_FLOW_SECURITY", line 2939 ORA-06512: at
"APEX_050100.HTMLDB_UTIL", line 3014 ORA-06512: at line 7 ORA-06512:
at line 7.
I also have tried to set security_group_id directly (apex_util.set_security_group_id(p_security_group_id => my_worspace_id or
wwv_flow_api.set_security_group_id(p_security_group_id=>my_worspace_id) but it always finish with the same error as my sample code. When i try to create job manually in sql developer it works. But when job is created by pl/sql process it finish with the mentioned error. Job is created successfully in both cases (pl/sql process or manually) with the same parameters so i do not understand why in case when job is created by pl/sql process it finish with error.
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"INVERTORY"."TEST"',
job_type => 'PLSQL_BLOCK',
job_action => 'begin
for c1 in (
select workspace_id
from apex_applications
where application_id = 104 )
loop
apex_util.set_security_group_id(p_security_group_id =>
c1.workspace_id);
end loop;
HTMLDB_MAIL.SEND(
p_to => ''****.****#****.com'',
p_from => ''noreply#****.com'',
p_subj => ''test mail'',
p_body => ''komu'');
end;',
number_of_arguments => 0,
start_date => TO_TIMESTAMP_TZ('2017-08-28 10:29:57.000000000 EUROPE/PRAGUE','YYYY-MM-DD HH24:MI:SS.FF TZR'),
repeat_interval => NULL,
end_date => NULL,
enabled => TRUE,
auto_drop => FALSE,
comments => '');
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"INVERTORY"."TEST"',
attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_OFF);
DBMS_SCHEDULER.enable(
name => '"INVERTORY"."TEST"');
END;
Try changing this :
for c1 in (
select workspace_id
from apex_applications
where application_id = 104 )
loop
apex_util.set_security_group_id(p_security_group_id =>
c1.workspace_id);
end loop;
To this :
SELECT MAX(workspace_id)
INTO v_workspace FROM apex_applications
WHERE application_id = 104;
--set workspace - declare v_workspace above as type number
wwv_flow_api.set_security_group_id(v_workspace)
In any event, it would be better to put your logic in a package in the database and create a job with job_type => 'STORED_PROCEDURE' and call on your procedure from there.

ORA-31600 when using scan_percent with dbms_comparison.compare

I'm using Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production and I've created a comparison using this code :
BEGIN
DBMS_COMPARISON.CREATE_COMPARISON(
comparison_name => 'test2',
schema_name => 'someSchema',
object_name => 'someTable',
dblink_name => 'MYORACLEDB',
scan_mode => 'RANDOM',
scan_percent => 50);
END;
WHen i execute the comparison using
DECLARE
consistent BOOLEAN;
scan_info DBMS_COMPARISON.COMPARISON_TYPE;
BEGIN
consistent := DBMS_COMPARISON.COMPARE(
comparison_name => 'test2',
scan_info => scan_info,
perform_row_dif => FALSE);
END;
I get the following error message :
ORA-31600: invalid input value 1 for parameter data type in function a_plus_b_mul_c_minus_d
ORA-06512: at "SYS.DBMS_COMPARISON", line 547
ORA-06512: at line 7
31600. 00000 - "invalid input value %s for parameter %s in function %s"
*Cause: A NULL or invalid value was supplied for the parameter.
*Action: Correct the input value and try the call again.
When i run a comparison with the full scan mode i've got no error.
Anybody encountered such issue ?

Resources