Oracle: define job_priority in a Job dbms_scheduler - oracle

I Want to create a job with the highest priority in Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'parseMsg',
job_type => 'PLSQL_BLOCK',
job_action => 'begin S_IN_TDK.parseMsg; end;',
repeat_interval => 'FREQ=SECONDLY;INTERVAL=1',
enabled => true,
job_priority => 1,
comments => 'Job that polls device n2 every 1 seconds');
END;
but I got this error:
Informe de error -
ORA-06550: line 2, column 3:
PLS-00306: wrong number or types of arguments in call to 'CREATE_JOB'
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

https://docs.oracle.com/database/121/ARPLS/d_sched.htm#ARPLS72302
Not all possible job attributes can be set with CREATE_JOB. Some must
be set after the job is created. For example, job arguments must be
set with the SET_JOB_ARGUMENT_VALUE Procedure or the
SET_JOB_ANYDATA_VALUE Procedure. Other job attributes, such as
job_priority and max_runs, are set with the SET_ATTRIBUTE Procedure.

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?

How to create a Redact Policy in oracle

I am trying to create a redact policy to hide NIC from Customer table for all users.
BEGIN
DBMS_REDACT.ADD_POLICY (
object_schema => 'RETAILX',
object_name => 'CUSTOMER',
column_name => 'NIC',
policy_name => 'REDACT_NIC_POLICY',
function_type => DBMS_REDACT.PARTIAL,
function_parameters => 'MDy1',
expression => '1=1'
);
END;
Above is my code for the policy creation. However, I am getting an error while creating the policy. Error as below.
ORA-06550: line 7, column 27:
PLS-00201: identifier 'DBMS_REDACT' must be declared
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
What Could be wrong here?

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 ?

How to present job_name to DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION

I am having trouble adding email notifications to Oracle 11g (11.2.0.1.0). It seems like a bug but I'm really not sure. I've tried doing this using SQL Developer to build the code as well as examples from the internet but it's not working.
I can create and enable a job easily enough:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"SCHEMA"."test1"',
job_type => 'PLSQL_BLOCK',
job_action => 'begin
null;
end;
',
auto_drop => FALSE
);
DBMS_SCHEDULER.enable(
name => '"SCHEMA"."test1"');
END;
/
anonymous block completed
As a precaution, I remove the job email notification - this works.
BEGIN
DBMS_SCHEDULER.REMOVE_JOB_EMAIL_NOTIFICATION (
job_name => '"SCHEMA"."test1"'
);
end;
/
anonymous block completed
But when I try to add an email notification it's as if it can't find the object, I'm working in my own schema and have the DBA role so I would have thought any potential permission issues should be overcome (though in my own schema I would have assumed I could make scheduled jobs easily enough)
BEGIN
DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
job_name => '"SCHEMA"."test1"',
recipients => 'email_address#test.com',
events => 'JOB_BROKEN, JOB_CHAIN_STALLED, JOB_FAILED, JOB_OVER_MAX_DUR, JOB_SCH_LIM_REACHED'
);
END;
/
ORA-27476: "SCHEMA.SCHEMA" does not exist
ORA-06512: at "SYS.DBMS_ISCHED", line 4856
ORA-06512: at "SYS.DBMS_ISCHED", line 7117
ORA-01403: no data found
ORA-06512: at "SYS.DBMS_SCHEDULER", line 4030
ORA-06512: at line 3
Note it says SCHEMA.SCHEMA as if it didn't read the line properly. When I change it from '"SCHEMA"."test1"' to 'test1' it still doesn't work but says ORA-27476: "SCHEMA.TEST1" does not exist.
All my jobs work correctly and behave and I have gotten a UTL_MAIL implementation going but I'd really like to get the oracle stuff working for simplicity if possible.
A possible issue is that by default object names in Oracle are case insensitive, unless you surround them with double quotes.
Here is a test case:
SQL> select * from v$version where rownum = 1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SQL> create user STACKOVERFLOW identified by STACKOVERFLOW;
User created.
SQL> grant connect, create job to STACKOVERFLOW;
Grant succeeded.
SQL> conn STACKOVERFLOW/STACKOVERFLOW
SQL> l
1 BEGIN
2 DBMS_SCHEDULER.CREATE_JOB (
3 job_name => '"STACKOVERFLOW"."test1"',
4 job_type => 'PLSQL_BLOCK',
5 job_action => 'begin
6 null;
7 end;
8 ',
9 auto_drop => FALSE
10 );
11 DBMS_SCHEDULER.enable(
12 name => '"STACKOVERFLOW"."test1"');
13* END;
SQL> /
PL/SQL procedure successfully completed.
If you name your job "test1" Oracle will create it with a lowercase name. You can confirm this by checking the catalog view dba_scheduler_jobs:
SQL> select owner, job_name from dba_scheduler_jobs where job_name = 'TEST1';
no rows selected
SQL> select owner, job_name from dba_scheduler_jobs where job_name = 'test1';
OWNER JOB_NAME
------------------------------ ------------------------------
STACKOVERFLOW test1
Therefore, this will work:
SQL> l
1 BEGIN
2 DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
3 job_name => '"STACKOVERFLOW"."test1"',
4 recipients => 'email_address#test.com',
5 events => 'JOB_BROKEN, JOB_CHAIN_STALLED, JOB_FAILED, JOB_OVER_MAX_DUR, JOB_SCH_LIM_REACHED'
6 );
7* END;
SQL> /
PL/SQL procedure successfully completed.
But this won't:
SQL> l
1 BEGIN
2 DBMS_SCHEDULER.ADD_JOB_EMAIL_NOTIFICATION (
3 job_name => '"STACKOVERFLOW".TEST1',
4 recipients => 'email_address#test.com',
5 events => 'JOB_BROKEN, JOB_CHAIN_STALLED, JOB_FAILED, JOB_OVER_MAX_DUR, JOB_SCH_LIM_REACHED'
6 );
7* END;
SQL> /
BEGIN
*
ERROR at line 1:
ORA-27476: "STACKOVERFLOW.STACKOVERFLOW" does not exist
ORA-06512: at "SYS.DBMS_ISCHED", line 4921
ORA-06512: at "SYS.DBMS_ISCHED", line 7613
ORA-01403: no data found
ORA-06512: at "SYS.DBMS_SCHEDULER", line 4063
ORA-06512: at line 2

Call stored procedure from PL/SQL Job

In sqlplus I created the procedure, whitch fill my table GeneratedData with int values...
create procedure fillGeneratedData (x in int) as
begin
for i in 1..x loop
insert into GeneratedData values (i);
end loop;
end;
/
I want to create job, whitch call this procedure, but it throws errors and dont call the procedure...
BEGIN
sys.dbms_scheduler.create_job(
job_name => 'job1',
job_type => 'PLSQL_BLOCK',
job_action => 'begin exec fillGeneratedData(50000); end;',
repeat_interval => 'FREQ=MINUTELY;INTERVAL=2',
start_date => systimestamp at time zone 'Europe/Belgrade',
auto_drop => FALSE,
enabled => TRUE);
END;
sqlplus says PL/SQL procedure successfully completed, but when i look to alert log, it throw error:
Tue Apr 01 00:50:45 2014
Errors in file c:\app\adbsuser\diag\rdbms\orcl\orcl\trace\orcl_j000_7516.trc:
ORA-12012: error on auto execute of job 74677
ORA-06550: line 1, column 734:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( # % ;
The symbol ";" was substituted for "" to continue.
Errors in file c:\app\adbsuser\diag\rdbms\orcl\orcl\trace\orcl_j000_7516.trc:
ORA-12012: error on auto execute of job 74679
ORA-06550: line 1, column 734:
PLS-00103: Encountered the symbol "FILLGENERATEDDATA" when expecting one of the following:
:= . ( # % ;
The symbol ":=" was substituted for "FILLGENERATEDDATA" to continue.
Can somebody help me?
Thanks a lot.
To start with, you PL/SQL block is not valid. If you tried to run just this
begin
exec fillGeneratedData(50000);
end;
you'd get an error. You don't use exec in a PL/SQL block-- that's a SQL*Plus command. Your PL/SQL block would just be
begin
fillGeneratedData(50000);
end;

Resources