Issue in submitting job using dbms_job() package
Hello all,
I need a st procedure to run on every 06:00 AM of the morning , kindly give me the syntax for submitting this job
Also give me the syntax for submitting this job to run for every 10 minutes.
Regards
Karthik Dinakaran
SQL> select sysdate from dual;
SYSDATE
22-dec-2005 12:40:02
SQL> select sysdate + 17.39/24, (sysdate + 17.39/24) + 10/60/24 from dual;
SYSDATE+17.39/24 (SYSDATE+17.39/24)+1
23-dec-2005 06:03:29 23-dec-2005 06:13:29
Similar Messages
-
Schedule a job using dbms_job package
SQL to schedule a job using DBMS_JOB.
variable jobno number;
variable status number;
begin
dbms_job.submit(:jobno, 'x(:status);', trunc(sysdate)+8/24,
'trunc(sysdate)+1+8/24', null);
commit;
end;
It fails and returns the following error ...
ORA-01008: not all variables bound
Is it possible to schedule a job to run a procedure with "IN OUT" parameter? I would appreciate any assistance.
Proc runs if I execute it from command mode and there are no issues.You cannot pass parameters back from a job-- Oracle spawns a separate session to run your job, so that session would receive any OUT parameters and end immediately after the job finishes. Even if Oracle let you do this, you would lose the OUT value as soon as the job ended.
If you want a job to return a status, you can-
1) Store the status in a table
2) Queue a status message in an Oracle Advanced Queue
3) Use dbms_alert to alert another process
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Scheduling job using DBMS_JOB.SUBMIT()
Hi people I hav esubmitted a job using DBMS_JOB.SUBMIT() package.I have set the time it should run after 5 minutes from the time i created.but now my question is how do we know the submitted job has been executed within specified interval?.am using oracle 9i.please suggest me.
Regards
VIDSYou should refer to DBA_JOBS and DBA_JOBS_RUNNING views to get information about your jobs
Please refer to this address to get more information about these views
http://pandazen.wordpress.com/2007/12/19/oracle-job-to-be-continued/
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Submitting Oracle job via OCCI using dbms_job package
I am using 10g client to connect to a 9i Database on Redhat Linux AS 3.0.
I am trying to submit a job via OCCI. I get back a jobId, but don't see the job in the user_jobs table or the result of the job being executed.
I am using occi::Statement in the following way :
stmt = connection->createStatement("begin dbms_job.submit(:v1, 'submitJobTest;', sysdate,'sysdate+1'); end;");
// where submitJobTest is a stored procedure
stmt->registerOutParam(1, OCCIINT);
stmt->executeUpdate();
int jobId = stmt->getInt(1);
I get back a job id, but can't find it in the user_jobs. The first time I executed the program, i got back jobId 0, then 1 and so on..
Any ideas? Do I need to use dbms_scheduler package?
Thanks, NiloferGood catch!
Had a bug, in that my autocommit was not being set!
Works now.
Thanks,
Nilofer -
1.I wanted to know if I can run a .sql file from the dbms_job package.
2. I also wanted to know the feature in oracle that I can use to send email to myself once the job is executed- showing successful execution or errors.
Thanks for your suggestions.You cannot pass parameters back from a job-- Oracle spawns a separate session to run your job, so that session would receive any OUT parameters and end immediately after the job finishes. Even if Oracle let you do this, you would lose the OUT value as soon as the job ended.
If you want a job to return a status, you can-
1) Store the status in a table
2) Queue a status message in an Oracle Advanced Queue
3) Use dbms_alert to alert another process
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Scheduling stored procedure using DBMS_JOB package
I have stored procedure called extract_every_day, I want this procedure to run automatically at 7:00 PM every day.
I used DBMS_JOB.SUBMIT to achieve this, below is pl/sql block
DECLARE
v_jobno number ;
BEGIN
DBMS_JOB.SUBMIT
(v_jobno,
' extract_every_day ',
TRUNC (SYSDATE) + 1 + 9/24,
'TRUNC (SYSDATE) + 1 + 9/24');
COMMIT;
END;
When I run above pl/sql block is that mean procedure extract_every_day executes every day and what is the significance of job OUT parameter in DBMS_JOB.SUBMIT procedure. Also how can I see list of jobs submitted.
Any help is appreciated.
ThanksThe OUT parameter is the unique number of the job being executed. This is the Sequence generated from sequence sys.jobseq
Also, in the example you have provided, the Job will run at 9Am and not 7PM.
To make it run at 7PM every day change the following lines :
'TRUNC (SYSDATE) + 1 + 9/24'
'TRUNC (SYSDATE) + 1 + 9/24'
To ,
'TRUNC (SYSDATE) + 19/24' <-- Changed
'TRUNC (SYSDATE) + 1 + 19/24' <-- Changed
Also do remember to include the parameter "job_queue_processes" parameter within the init.ora file. This parameter is used to determine the max no
of concurrently running jobs (i.e. Set in Init.ora).
NOTE :- Job_queue_process cannot be set to 0. If set to 0, no jobs is run.
he view dba_jobs and dba_jobs_running should be used to view the jobs.
-- Shailender Mehta -- -
To submit a job in dbms_job package with specific durations
Hi,
Want to set a job to run everyday from 8.00 am to 6.00 pm for every 30 min after that every hour.I want to set this in dbms_job package.The database is 10.2.0.3
The implementation notation used is
variable jobno number;
exec dbms_job.submit(:jobno,'begin procedurename; end;',sysdate,
'case when sysdate-trunc(sysdate)>=8/24 and sysdate-trunc(sysdate)<18/24 then sysdate+30/1440 else sysdate+1/24');
but the error resulted is parameter value not appropriate.Hi,
Obviously because you have two different interval strings 'sysdate+30/1440' and 'sysdate+1/24'.
(The interval strings are inaccurate, but that's a different story)
The preferred solution in 10g would be to use dbms_scheduler.
A workaround using dbms_job would be to use 2 ancilliary jobs to change the interval of your main job twice a day, calling dbms_job.interval.
Your interval strings will cause the time to drift.
You need to use trunc(sysdate,'HH24') instead of just sysdate.
Hth
Sybrand Bakker
Senior Oracle DBA -
Is this the correct syntax to submit a job using DBMS_JOB.SUBMIT?
Hello,
Is this the correct syntax to submit a job?
DECLARE
v_job_number NUMBER;
v_job_command VARCHAR2(1000) := 'PREPARE_ORACLE_TEXT_SEARCH;';
v_interval VARCHAR2(1000) := 'trunc(SYSDATE)+1+7/24';
BEGIN
DBMS_JOB.SUBMIT(v_job_number, v_job_command, sysdate, v_interval, false);
COMMIT;
END;
Thanks
DougDECLARE
v_job_number NUMBER;
v_job_command VARCHAR2(1000) := 'BEGIN
PREPARE_ORACLE_TEXT_SEARCH; END;';
v_interval VARCHAR2(1000) :=
'trunc(SYSDATE)+1+7/24';
BEGIN
DBMS_JOB.SUBMIT(v_job_number, v_job_command, sysdate,
v_interval, false);
COMMIT;
END;
About your error:
PLS-00201: identifier 'PREPARE_ORACLE_TEXT_SEARCH'
must be declared
ORA-06550: line 1, column 96:
PL/SQL: Statement ignored
The problem is that the job cannot find the procedure
(maybe own by an other user). The user who run the
job is not the same as the owner of the package.
Bye, AronYou forget the semicolon after END.
But we don't need here begin - end Block.
So it's OK.
v_job_command VARCHAR2(1000) := 'PREPARE_ORACLE_TEXT_SEARCH;'[b];
As you right mentioned, it is probably problem with owner or typo in the name of procedure.
Regards
Dmytro Dekhtyaryuk
Message was edited by:
dekhtyar -
How can event driven scheduling will be acheived using DBMS_JOB
Hi,
I am running oracle jobs using DBMS_JOB package . I need to check for particular event is happend or not then only It should run my job.Can I acheive this using dbms_job.What is the syntax for it.Where Can i add dependencies in dbms_job
ThanksJob 1 - finishes 2 AM
Job 2 should start right after Job 1 , this is a dependency tree and dbms_job is not good at this.
If this is your requirement then you have to build your own wrappers on top of dbms_job to make it happen. Simplest is to loop and wait till job 1 finishes and then launch job 2. -
Hi Everyone,
I assinged a job using dbms_job package whose interval is after every 5 minutes. But the jobs are not activated i.e, not running. Can anybody explain me to solve this problem.
Thanks
KrishnaHi, Krishna
Also, you may need to change some initialization parameters in your database.
In order for jobs to be executed, you have to define how many processes will be ready to execute jobs.
You will also have to define how frequently the database checks for jobs (the default is every 10 minutes).
Both values are defined in the INIT<databasename>.ORA file.
Examples:
job_queue_processes = 2
job_queue_interval = 60 (seconds)
The lower the interval, the slower the database. Adjust the number of processes according to the number of simultaneous jobs.
You can check if the values are already defined by the following query:
select name, value from v$parameter
where name like '%job%';If you change the init.ora file, remember to shutdown and restart your database.
Hope this gets you started,
Pedro. -
How to schedule a job to run after completion of each run using DBMS_JOB ?
Hi Gurus,
Please let me know if the subject requirement can be fulfilled. I want to schedule a job using DBMS_JOB to run a script sequentially after completion of each run.
Thanks in advance.
SantoshHi Santosh
Instead to use the old dbms_job package use the dbms_scheduler and raise / catch events.
Oracle create dbms_scheduler also for this purpose you need.
You can find tons of examples on the web.
Aurelio -
How to use DBMS_JOB to run the OWB scripts?
Can anyone pls explain how I can use the DBMS_JOB to run the scripts which are generated by OWB.
SuroopCREATE OR REPLACE PACKAGE "LOAD_DATAMART"
AS
TYPE t_global IS RECORD
( plsql_map VARCHAR2(50) := 'transactions_map_exp', -- Default mapping plsql program
plsql_map_main VARCHAR2(50) := 'transactions_map_exp.main', -- Default mapping plsql main program
servers NUMBER(2) := 19, -- Default concurrent loading servers
max_reloads NUMBER(3) := 3 , -- Default maximum load retrys
mail_sender VARCHAR2(99) := '"Certegy Data Warehouse"', -- Default Mail Sender
mail_notice VARCHAR2(99) := '[email protected]', -- Default Recepient Notification
mail_error VARCHAR2(99) := '[email protected]' -- Default Recepient for Errors.
GLOBAL t_global ;
PROCEDURE start_monitor_load(p_date IN DATE);
PROCEDURE monitor_load( p_date IN DATE , p_dwh_load# IN NUMBER DEFAULT NULL, p_servers IN NUMBER DEFAULT GLOBAL.servers );
PROCEDURE start_load(p_dwh_load# IN NUMBER, p_load_seq IN NUMBER, p_rbs IN VARCHAR2);
PROCEDURE create_job_load(p_dwh_load# IN NUMBER, p_load_seq IN NUMBER, p_rbs VARCHAR2 DEFAULT 'batch01_rbs' );
FUNCTION dependency_on(p_type IN VARCHAR2, p_date IN DATE) RETURN BOOLEAN;
PROCEDURE send_mail (p_sender IN VARCHAR2, p_recipient IN VARCHAR2, p_subject IN VARCHAR2, p_message IN VARCHAR2);
PROCEDURE start_load_guard;
PROCEDURE load_guard(p_job IN INTEGER);
END load_datamart;
CREATE OR REPLACE PACKAGE BODY "LOAD_DATAMART"
AS
PROCEDURE start_monitor_load(p_date IN DATE) IS
v_plsql VARCHAR2(32000);
BEGIN
v_plsql := 'load_datamart.monitor_load(to_date('''||TO_CHAR(p_date,'DD-MON-YYYY HH24:MI:SS')||''',''DD-MON-YYYY HH24:MI:SS''));';
EXECUTE IMMEDIATE 'declare v_job integer; begin dbms_job.submit(v_job,:v_plsql); end;'
USING v_plsql;
END start_monitor_load;
PROCEDURE monitor_load( p_date IN DATE, p_dwh_load# IN NUMBER DEFAULT NULL , p_servers IN NUMBER DEFAULT GLOBAL.servers ) IS
TYPE t_server IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
v_server t_server;
v_dwh_load# NUMBER;
v_reload_limit NUMBER := 0;
v_plsql_error VARCHAR2(32000);
pending_jobs BOOLEAN;
p_batch VARCHAR2(20) := 'batch01_rbs';
FUNCTION job_server_running(p_dwh_load_seq NUMBER) RETURN BOOLEAN IS
CURSOR c1 IS SELECT * FROM DWH_LOAD_DETAIL
WHERE dwh_load# = v_dwh_load#
AND load_seq = p_dwh_load_seq;
r1 c1%ROWTYPE;
PROCEDURE try_resubmit_job(p_dwh_load_seq OUT NUMBER) IS
v_load_seq NUMBER;
BEGIN
SELECT COUNT(*) INTO v_load_seq
FROM DWH_LOAD_DETAIL
WHERE dwh_load# = v_dwh_Load#;
IF v_load_seq < v_reload_limit THEN
INSERT INTO DWH_LOAD_DETAIL(dwh_load#,load_seq,load_server,plsql_map,map_parameters)
VALUES(v_dwh_load#,v_load_seq+1,0,r1.plsql_map,r1.map_parameters||'| SEQ '||v_load_seq);
COMMIT;
ELSE
RAISE_APPLICATION_ERROR(-20000,'Maximum '||v_reload_limit||' retrys reached, load aborted.');
END IF;
END;
BEGIN
OPEN c1;
FETCH c1 INTO r1;
IF c1%NOTFOUND THEN
RETURN FALSE;
ELSIF c1%FOUND AND r1.job_end_time IS NULL THEN
RETURN TRUE;
ELSIF c1%FOUND AND r1.job_end_time IS NOT NULL THEN
IF r1.job_end_time = 'BROKEN' THEN
try_resubmit_job(r1.load_seq); -- Oracle Errors
END IF;
RETURN FALSE;
END IF;
CLOSE c1;
END job_server_running;
FUNCTION get_next_load_seq(p_dwh_load_server IN NUMBER) RETURN NUMBER IS
CURSOR c1 IS SELECT * FROM DWH_LOAD_DETAIL
WHERE dwh_load# = v_dwh_load#
AND load_server = 0
ORDER BY dwh_load#,load_seq
FOR UPDATE OF load_server;
r1 c1%ROWTYPE;
BEGIN
OPEN c1;
FETCH c1 INTO r1;
IF c1%FOUND THEN
UPDATE DWH_LOAD_DETAIL
SET load_server = p_dwh_load_server
WHERE CURRENT OF c1;
END IF;
CLOSE c1;
COMMIT;
RETURN r1.load_seq;
END get_next_load_seq;
BEGIN
v_dwh_load# := p_dwh_load#;
-- Defining the Max Retry to load
SELECT COUNT(*) + GLOBAL.max_reloads INTO v_reload_limit
FROM DWH_LOAD_DETAIL
WHERE dwh_load# = v_dwh_load#;
FOR i IN 1..99 LOOP
v_server(i) := NULL;
END LOOP;
LOOP
pending_jobs := FALSE;
FOR i IN 1..p_servers LOOP
IF NOT job_server_running(v_server(i)) THEN
v_server(i) := get_next_load_seq(i);
IF v_server(i) IS NOT NULL THEN
load_datamart.create_job_load(v_dwh_load#,v_server(i),p_batch);
IF p_batch = 'batch01_rbs' THEN
p_batch :='batch02_rbs';
ELSIF p_batch = 'batch02_rbs' THEN
p_batch :='batch03_rbs';
ELSIF p_batch = 'batch03_rbs' THEN
p_batch :='batch01_rbs';
END IF;
END IF;
END IF;
IF v_server(i) IS NOT NULL THEN
pending_jobs := TRUE;
END IF;
END LOOP;
EXIT WHEN NOT pending_jobs;
dbms_lock.sleep(05);
END LOOP;
COMMIT;
UPDATE DWH_LOAD_HEADER
SET plsql_error = 'Completed'
WHERE dwh_load# = v_dwh_load#;
COMMIT;
EXCEPTION WHEN OTHERS THEN
v_plsql_error := SUBSTR(SQLERRM,1,4000);
load_datamart.send_mail(load_datamart.GLOBAL.mail_sender,load_datamart.GLOBAL.mail_error,
'Load Datamart - Load '||TO_CHAR(p_date,'MM/DD/YYYY HH24:MI:SS')||' not completed',
v_plsql_error||CHR(10)||
':::::::::::::::::::::::::::::::::::::::::'||CHR(13)||
'- Parameter Date '||TO_CHAR(p_date,'MM/DD/YYYY')||CHR(13)||
':::::::::::::::::::::::::::::::::::::::::'||CHR(13)||
'- Transmission time '||TO_CHAR(p_date,'hh24:mi:ss')||CHR(13)||
'- Load Seq# '||TO_CHAR(v_dwh_load#)||CHR(13)||
':::::::::::::::::::::::::::::::::::::::::'||CHR(13));
v_plsql_error := SUBSTR(SQLERRM,1,4000);
UPDATE DWH_LOAD_HEADER
SET plsql_error = v_plsql_error
WHERE dwh_load# = v_dwh_load#;
COMMIT;
RAISE_APPLICATION_ERROR(-20000,v_plsql_error);
END monitor_load;
PROCEDURE start_load(p_dwh_load# IN NUMBER, p_load_seq IN NUMBER, p_rbs IN VARCHAR2) IS
v_plsql_map VARCHAR2(200);
v_sqlerrm VARCHAR2(4000);
BEGIN
UPDATE DWH_LOAD_DETAIL
SET job_start_date = TRUNC(SYSDATE) ,
job_start_time = TO_CHAR(SYSDATE,'HH24:MI:SS')
WHERE dwh_load# = p_dwh_load#
AND load_seq = p_load_seq
RETURN plsql_map INTO v_plsql_map;
COMMIT;
EXECUTE IMMEDIATE 'set transaction use rollback segment '||p_rbs;
v_plsql_map := 'begin '||v_plsql_map||' end;';
EXECUTE IMMEDIATE v_plsql_map;
EXECUTE IMMEDIATE 'begin
UPDATE DWH_LOAD_DETAIL
SET job_end_date = SYSDATE,
job_end_time = TO_CHAR(SYSDATE,''HH24:MI:SS''),
rta_iid = '||global.plsql_map||'.get_runtime_audit_id,
rta_select = '||global.plsql_map||'.get_selected,
rta_update = '||global.plsql_map||'.get_updated,
rta_insert = '||global.plsql_map||'.get_inserted,
rta_errors = '||global.plsql_map||'.get_errors,
rta_delete = '||global.plsql_map||'.get_deleted
WHERE dwh_load# = :p_dwh_load#
AND load_seq = :p_load_seq;
UPDATE DWH_LOAD_HEADER
SET rows_inserted = NVL(rows_inserted,0) + NVL('||global.plsql_map||'.get_inserted,0)
WHERE dwh_load# = :p_dwh_load#;
END;' using p_dwh_Load#,p_load_seq;
COMMIT;
EXCEPTION WHEN OTHERS THEN
v_sqlerrm := SUBSTR(SQLERRM,1,3999);
EXECUTE IMMEDIATE ' begin
UPDATE DWH_LOAD_DETAIL
SET job_end_date = SYSDATE,
job_end_time = ''BROKEN'',
rta_iid = '||global.plsql_map||'.get_runtime_audit_id,
rta_select = '||global.plsql_map||'.get_selected,
rta_update = '||global.plsql_map||'.get_updated,
rta_insert = '||global.plsql_map||'.get_inserted,
rta_errors = '||global.plsql_map||'.get_errors,
rta_delete = '||global.plsql_map||'.get_deleted,
plsql_error = :v_sqlerrm
WHERE dwh_load# = :p_dwh_load#
AND load_seq = :p_load_seq;
UPDATE DWH_LOAD_HEADER
SET rows_inserted = NVL(rows_inserted,0) + NVL('||global.plsql_map||'.get_inserted,0)
WHERE dwh_load# = :p_dwh_load#;
END; ' using v_sqlerrm, p_dwh_load#,p_load_seq;
COMMIT;
END start_load;
PROCEDURE create_job_load(p_dwh_load# IN NUMBER, p_load_seq IN NUMBER, p_rbs VARCHAR2 DEFAULT 'batch01_rbs' ) IS
p_job INTEGER;
v_date DATE;
BEGIN
-- Submitting Job Load
DBMS_JOB.SUBMIT(p_job,'load_datamart.start_load('||p_dwh_load#||','||p_load_seq||','||''''||p_rbs||''');');
COMMIT;
END create_job_load;
FUNCTION dependency_on(p_type IN VARCHAR2, p_date IN DATE) RETURN BOOLEAN IS
CURSOR c1 IS SELECT * FROM DWH_DATA_LOADS
WHERE data_type = p_type
AND file_date >= TRUNC(p_date);
r1 c1%ROWTYPE;
BEGIN
OPEN c1;
FETCH c1 INTO r1;
IF c1%FOUND AND r1.status = 'Done' THEN
RETURN FALSE;
END IF;
CLOSE c1;
RETURN TRUE;
END;
PROCEDURE send_mail (p_sender IN VARCHAR2,
p_recipient IN VARCHAR2,
p_subject IN VARCHAR2,
p_message IN VARCHAR2) IS
* This procedure is usefull for sending e-mails for single or multiples recipients up to 50 *
* the limitation is Lotes Notes e-mail service. *
* Lewis Cunnigham Package is good also for massive distribuition to multiples e-mails, *
v_mailhost VARCHAR2(30) := '172.27.2.157'; -- Titan and Eagle available SMTP service, through the GATEWAY
v_mailhost VARCHAR2(30) := 'STPMTA1ML'; old one
v_mailhost VARCHAR2(30) := 'stpnh1ml'; Main SMTP, all other are replicated, not available.
v_mailhost VARCHAR2(30) := 'STPMS6ML'; Replicated server, not available.
v_mail_conn utl_smtp.connection;
v_crlf VARCHAR2(2) DEFAULT CHR(13)||CHR(10);
v_date VARCHAR2(255) DEFAULT TO_CHAR( SYSDATE, 'MM/DD/YYYY hh24:mi AM' ); -- Lotus Notes default format.
--pragma autonomous_transaction;
PROCEDURE writeData( p_text IN VARCHAR2 ) AS
BEGIN
IF ( p_text IS NOT NULL ) THEN
utl_smtp.write_data( v_mail_conn, p_text || v_crlf );
END IF;
END;
BEGIN
v_mail_conn := utl_smtp.open_connection(v_mailhost, 25); -- Default port
utl_smtp.helo(v_mail_conn, v_mailhost);
utl_smtp.mail(v_mail_conn, p_sender);
utl_smtp.rcpt(v_mail_conn, p_recipient);
utl_smtp.open_data(v_mail_conn);
writeData( 'To: '|| p_recipient ); -- Redundant, but necessary to complete format
writeData( 'From: ' || p_sender); -- Redundant, but necessary to complete format
writeData( 'Date: ' || v_date ); -- Database completion time
writeData( 'Subject: ' || NVL( p_subject , '(no subject) ' ) ); -- Default Subject
--writeData( 'Content-Type: text/html');
utl_smtp.write_data(v_mail_conn, '' || v_crlf );
utl_smtp.write_data(v_mail_conn, p_message ); -- Message body
utl_smtp.close_data(v_mail_conn );
utl_smtp.quit(v_mail_conn);
--commit;
EXCEPTION WHEN OTHERS THEN null; Since we are just sending e-mails,
-- We don't care about mail errors like when server down, only when needed.
END;
PROCEDURE start_load_guard IS
v_job INTEGER;
BEGIN
DBMS_JOB.SUBMIT(v_job,'load_datamart.load_guard(100);',SYSDATE+100);
DBMS_JOB.CHANGE(v_job,'load_datamart.load_guard('||v_job||');',SYSDATE,'sysdate+((1/60)*1/24)');
COMMIT;
END start_load_guard;
PROCEDURE load_guard(p_job IN INTEGER) IS
v_job INTEGER;
CURSOR c1 IS SELECT * FROM DWH_DATA_LOADS
WHERE file_date BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE)+(86399/86400);
did_PAYC_load BOOLEAN := NULL;
did_ARMS_load BOOLEAN := NULL;
did_CLMS_load BOOLEAN := NULL;
did_STAT_load BOOLEAN := NULL;
did_TRAN_load BOOLEAN := NULL;
did_VCOM_load BOOLEAN := NULL;
did_BCRD_load BOOLEAN := NULL;
did_PNET_load BOOLEAN := NULL;
BEGIN
FOR i IN c1 LOOP
NULL;
--if i.status in ('Ready','Done') then
--if i.data_type = 'PAYC' then
END LOOP;
IF NOT ( SYSDATE >= TO_DATE(TO_CHAR(SYSDATE,'DD-MON-YYYY')||' 13:35:00','DD-MON-YYYY HH24:MI:SS') )THEN
send_mail('"Load Datamart"','[email protected]','I am the guard','This is my body messaje at '||TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS')||'.');
ELSE
send_mail('"Load Datamart"','[email protected]','I am the guard, this is the last message.','This is my body messaje at '||TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS')||'.');
DBMS_JOB.SUBMIT(v_job,'begin dbms_job.next_date('||p_job||',to_date('''||TO_CHAR(SYSDATE+1,'DD-MON-YYYY')||' 03'||''',''DD-MON-YYYY HH24'')); commit; exception when others then null; end;',TRUNC(SYSDATE));
END IF;
COMMIT;
EXCEPTION WHEN OTHERS THEN
load_datamart.send_mail('"Load Datamart"','[email protected]','I am the guard, I break at '||TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'),SQLERRM);
END load_guard;
END load_datamart; -
SQL works from SQL*Plus command line but not as a DBMS_JOB submitted job
Oracle 10g 10.2
Got a procedure which does not run correctly as an Oracle job but runs fine as a SQL script.
There are no Oracle errors (or any errors) of any kind when the job does not run fine – it just does not update any rows. But when run as a SQL script – the same way it is run as a job – then the rows are updated.
Any ideas?Good stuff....
See my replies to some of the questions in italics
a) Different NLS settings => The job uses the NLS settings of the session that created it. If you create it with some tool like TOAD, you might have a different environment than with sql*plus. Runs good in TOAD and SQL*Plus using the command-line feature - just 'acts funky' when submitted.
b) Interval issue. Are you sure the job was running? Isn't still running? The job runs successfully - even logs a successful message in our logging table.
c) User/priviledge issue. Sometimes a job needs direct grants whereus a procedure can be called with priviledges granted through roles. Don't know - need to check this out.
d) Transaction handling / Error Handling. The job runs into some error, but the error is supressed, because of bad exception handling. What is the value in the BROKEN column, when you do: select * from user_jobs; I would think that, since the errors are logged into a side table, an error would be found there. However, no errors are found. The BROKEN column is 'N'. -
Want job to execute at 00 , 30 mins every hour using dbms_job.
Hi All
Oracle 9.2 , Solaris 8
I want to schedule a job every 30 mins using dbms_job. it should run exactly as
12:00 then
12:30
22:00 and so on.
So the interval should be 30 mins , but it should run sharp at beginning of an hour and half past that hour.
Can you provide me the logic for interval.
Thanks in advanceSQL> select sysdate,trunc(sysdate)+ceil((sysdate-trunc(sysdate))*60*24/30)/2/24 from dual;
SYSDATE TRUNC(SYSDATE)+CEIL
06/12/2010 15:50:16 06/12/2010 16:00:00
SQL> select sysdate,trunc(sysdate)+ceil((sysdate-trunc(sysdate))*60*24/30)/2/24 from dual;
SYSDATE TRUNC(SYSDATE)+CEIL
06/12/2010 16:07:06 06/12/2010 16:30:00Nicolas. -
SCHEDULER with using dbms_job.submit package
i want to use a procedure in SCHEDULER with using dbms_job.
How i use this procedure in SCHEDULER
Plz, Help me
Message was edited by:
Nilesh HoleHi,
For 10g and up you should be using dbms_scheduler for scheduling. Some examples are here
http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/scheduse.htm#i1033533
and the homepage is at
http://www.oracle.com/technology/products/database/scheduler/index.html
Here's an example that runs daily at 2am
begin
dbms_scheduler.create_job('myjob',
job_type=>'plsql_block',
job_action=>'dbms_lock.sleep(10);',
start_date=>null,
repeat_interval=>'freq=daily;byhour=2;byminute=0',
enabled=>true , auto_drop=>true
end;
/Hope this helps,
Ravi.
Maybe you are looking for
-
How can i delete my old account, for create a new one?
i need to delete my old account for create a new one bicouse i arrived to the limiterd creation of ID account apple (5 TIME) with the seme payment card.the proublem is tht i don't now what ID account i have and wat i need to deleted so i need to find
-
Query to populate an alert message to avoid the duplication of Reference no
Hi Experts, SUB:Query to populate an alert message to avoid the duplication of BP reference no. In A/R invoice, BP reference (numAtcard) is used to enter sales Order no as the reference number. As human error, double A/R invoice is created to that pa
-
Problem with non-interactive client's installation
Hi, I'm trying to install Oracle 9i's client in Non-Interactive mode. I have modified clientcustom.rsp and netca.rsp modifying same parameters but the installation doesn't work. The client is installed but netca never appears. I realized Network's ut
-
Add Column with Varchar2 function
i created a program unit (function) that returns a varchar2(100). How do i create a link between the function and a new column on the report for each record? I created a query that returns two columns now i want to apply this function to a third colu
-
Using field symbols in OOPs programming...have ur points.
Hi all, I want to use field symbols in OOPS programming like this... But the system is giving me dump....help me. START-OF-SELECTION. CREATE OBJECT OBJ. FIELD-SYMBOLS : <AB> TYPE ANY. ASSIGN OBJ TO <AB>. CALL METHOD <AB>->add EXPORTING a =