Sysdate on dbms_job Next_date
Hi, actually i did post this before, i gonna repost again since no one reply me
my current code is like this:
DECLARE
JOBNUMBER NUMBER;
BEGIN
dbms_job.submit(JOB => jobnumber,
WHAT => 'BEGIN .........end;',
NEXT_DATE => to_date('26/06/2009 23:00','DD/MM/YYYY HH24:MI'),
INTERVAL => '(SYSDATE) + 1' );
COMMIT;
END;how to make it run on today date (sysdate) with the run time set on 11pm. The all_jobs should be like this:
Job LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE NEXT_SEC TOTAL_TIME TOTAL INTERVAL
525 26-JUN-09 23:00:00 (null) (null) 27-JUN-09 23:00:35 21.00000000000000000000000000000000000004 (sysdate) + 1Thanks
Edited by: newBJeat on Jun 26, 2009 12:40 AM
Edited by: newBJeat on Jun 26, 2009 12:48 AM
Hi
Current code works fine, but didn't work as what i want. Yeah in my case both are null, like this:
Job LAST_DATE LAST_SEC THIS_DATE THIS_SEC NEXT_DATE NEXT_SEC TOTAL_TIME TOTAL INTERVAL
530 (null) (null) (null) (null) 26-06-2009 23:00:00 23:00:00 (SYSDATE) + 1I just need the job run everyday exactly on 11pm follow the system date and keep run routine without user to run manually....I just don't know how the sysdate format is? (like what in my code
NEXT_DATE => to_date('26/06/2009 23:00','DD/MM/YYYY HH24:MI'),where sysdate have to place in my code???
Thanks
Edited by: newBJeat on Jun 26, 2009 1:02 AM
Edited by: newBJeat on Jun 26, 2009 1:06 AM
Similar Messages
-
DBMS_JOB.RUN: cannot run a job from a job
I'm trying to set up a job to automatically run every October 1st. The "submit" part of this job is pretty simple, but I am getting some errors on the "run" part:
declare
job_nbr binary_integer;
BEGIN
dbms_job.submit(job => job_nbr,
what => 'RESET_ORDER_NBR_SEQ;',
next_date => to_date('10/1/2008', 'mm/dd/yyyy'),
interval => 'add_months(sysdate,12)');
dbms_job.run(job_nbr);
COMMIT;
END;
When I run this script, I get the following error: "ORA-32317: cannot run a job from a job". I know this is due to the dbms_job.run because I don't get the error when I comment this line out. Also, even when I moved the dbms_job.run into its own script (and even hard-coded the job_nbr, so the dbms_job.run was the only line in the script), it still gave me the same error. This is working in SQL Developer when but not in Application Express. It seems to be something specific to the "run", since "submit" and "remove" work fine. Has anyone had any problems like this?MBETTIS,
Rather than including dbms_job.run in your PL/SQL block, why don't you just schedule the job to run via next_date?
Also, the interval will be computed after the job successfully executes. So if your job takes 5 minutes to run, the value of SYSDATE in your interval may "slide" after each execution. Consider using some form of TRUNC against the SYSDATE in your interval if you want to achieve a consistent execution time.
Joel -
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; -
Dbms_job.next_time from inside a job
Hi all.
I have a procedure that collects data from a remote database. Normally it runs every 2.5 hour.
I want to ensure that if the jobs run after 18:00, next date is set to next morning 08:30 AM or if the job runs on friday after 18:00 I want to set next time monday morning at 08:30. So, I have created a block inside the procedure that tests using sysdate, but no changes are made to the next date in the job definition.
The following block exists inside the procedure;
DECLARE
njob INTEGER;
BEGIN
bms_output.put_line('Inside time change block');
IF TO_NUMBER (TO_CHAR (sysdate, 'HH24')) > 11 THEN
SELECT job INTO njob
FROM dba_jobs
WHERE LOWER (what) LIKE '%agr2sn%';
IF upper(TO_CHAR(sysdate,'DAY')) like 'FRIDAY%' THEN
dbms_output.put_line('Day is friday, change accordingly');
dbms_job.next_date (njob, TRUNC (sysdate) + 3 + 8.5 / 24);
commit;
ELSE
dbms_job.next_date (njob, TRUNC (sysdate) + 1 + 8.5 / 24);
dbms_output.put_line('Not friday,change to tomorrow morning');
commit;
END IF;
END IF;
END;
So, this procdure changes next date if i run it from sqlplus with:
exec agr2sn;
But running it as the job does not change the date. This is rather natural since the last thing the job does is to call the job-queue with the next date from the interval from within the job definition.
Anyone that has an idea on how to solve this problem?
Best Regards
Kjell OveYou need to specify the interval when you initially submit the job. Also, it is easier to use 'DY' and compare to 'FRI' because 'DAY' actually returns a string that is padded to 9 characters, so you would either have to trim the extra characters or compare to 'FRIDAY' plus three spaces. Please see the example below that uses a function to calculate the interval based on your criteria.
CREATE OR REPLACE FUNCTION calculate_interval
(p_date IN DATE)
RETURN DATE
AS
BEGIN
IF TO_CHAR (SYSDATE, 'HH24') > '18'
THEN
IF TO_CHAR (SYSDATE, 'DY') = 'FRI'
THEN RETURN NEXT_DAY (TRUNC (SYSDATE), 'MON') + 8.5 / 24;
ELSE RETURN TRUNC (SYSDATE) + 8.5 / 24;
END IF;
ELSE RETURN SYSDATE + 2.5 / 24;
END IF;
END calculate_interval;
DECLARE
njob INTEGER;
BEGIN
DBMS_JOB.SUBMIT
(njob,
'agr2sn;',
SYSDATE,
'calculate_interval (SYSDATE)');
COMMIT;
END; -
Help on DBMS_JOB in Forms 6i
Hi all,
I am trying to use the DBMS_JOB but I am having a bit of difficult.
I read the Notes on 'How to use DBMS_JOB package from Forms', I have forgotten the Notes number and followed it and it worked very well for me.
For the benefit of those who cant remember the number of the Note, I have reprint the content below at the tail end.
My problem is that because I want to determine the name of the 'wrapper procedure' at runtime, I used variables to write my create procedure statment as follows
declare
v_proc_name varchar2(30) := 'Test_Job8';
v_run_proc varchar2(30) := 'ProcName';
v_proc_touse varchar2(100);
v_ddl_stm varchar2(500):= ''' ';
begin
v_proc_touse := '( '||v_run_proc||' Varchar2 )';
v_ddl_stm := v_ddl_stm||'Create or Replace Procedure ';
v_ddl_stm := v_ddl_stm||v_proc_name;
v_ddl_stm := v_ddl_stm||v_proc_touse;
v_ddl_stm := v_ddl_stm||' as Jobid number := 0; ProcNm Varchar2(30); ';
v_ddl_stm := v_ddl_stm||'Begin ';
v_ddl_stm := v_ddl_stm||'ProcNm := ';
v_ddl_stm := v_ddl_stm||'''';
v_ddl_stm := v_ddl_stm||'''';
v_ddl_stm := v_ddl_stm||'Begin ';
v_ddl_stm := v_ddl_stm||'''';
v_ddl_stm := v_ddl_stm||'''';
v_ddl_stm := v_ddl_stm||'||';
v_ddl_stm := v_ddl_stm||v_run_proc;
v_ddl_stm := v_ddl_stm||'||';
v_ddl_stm := v_ddl_stm||'''';
v_ddl_stm := v_ddl_stm||''';';
v_ddl_stm := v_ddl_stm||' End;';
v_ddl_stm := v_ddl_stm||'''';
v_ddl_stm := v_ddl_stm||''' ';
v_ddl_stm := v_ddl_stm||' ;';
v_ddl_stm := v_ddl_stm||' Dbms_job.Submit(Jobid,ProcNm,Sysdate,null); Dbms_job.run(Jobid); ';
v_ddl_stm := v_ddl_stm||'End; ';
v_ddl_stm := v_ddl_stm||' ''';
FORMS_DDL(v_ddl_stm);
end;
Well the long assignments is to allow me follow what I am doing. When I execute this statement the procedure does not get created.
However if I execute the following code, it executes
FORMS_DDL( ' Create or replace procedure Test_job13(ProcName Varchar2) as Jobid Number := 0;
ProcNm Varchar2(30);
Begin
ProcNm := ''Begin ''||ProcName||''; End;'';
Dbms_job.Submit(Jobid,ProcNm,Sysdate,null);
Dbms_job.run(Jobid);
End;
CAN ANYONE HELP ME OUT PLEASE.
Thanks Jake
------ Content of Note on 'How to use DBMS_JOB package from Forms' ------
Best way to execute DBMS_JOB procedures from Forms is through a wrapper
procedure :
1. Create a Procedure named Dept_Insert. This procedure will insert a row into
the Dept table present in the SCOTT schema.
Create or Replace Procedure Dept_Insert As
Begin
Insert into dept values(70,'DDDDDDDDD','DDDDDDDD');
Commit;
End;
2. Create a wrapper procedure named Test_Job, which will execute the
Dept_Insert procedure.
Create or replace procedure Test_job(ProcName Varchar2) as
Jobid Number := 0;
ProcNm Varchar2(30);
Begin
ProcNm := 'Begin '||ProcName||'; End;';
Dbms_job.Submit(Jobid,ProcNm,Sysdate,null);
Dbms_job.run(Jobid);
End;
3. Create a Simple Form with a Button. In the When-Button-Pressed trigger
write the following code:
Begin
Test_Job('Dept_Insert');
End;
4. From Sql*Plus session check whether the row is inserted in the Dept table.Hi,
I guess my statement had an apostrophe that is should not have, at the beginning and the end.
I think I might be able to resolve it.
Thanks to all for your time. -
ORA-01426: numeric overflow when creating job
Hello,
When executing the following script to create a job I get the error "ORA-01426: numeric overflow" . When I execute the same script on another database with same version and same configuration I do not get the error and the job is created.
Can anyone help me out solving this issue?
Script:
DECLARE
X NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT
( job => X
,what => 'insert into dba.dba_logs values (''SGC'',''TRL03'',sysdate,null);
commit;
,next_date => to_date('07-11-2010 02:00:00','dd/mm/yyyy hh24:mi:ss')
,interval => 'NEXT_DAY(TRUNC(SYSDATE)+2/24,''SUNDAY'')'
,no_parse => FALSE
SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
COMMIT;
END;
Database version: 11.2.0.1
OS: HPUXWe are planning to migrate to dbms_scheduler, but that's in the future. for now we have this error first to solve.
We also tried the following with dbms_scheduler and it gives the same error. The strange is that in another database with same version and same OS it works fine.
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB
job_name => 'JOB_CLIENTES_IN'
,start_date => SYSTIMESTAMP
,repeat_interval => 'FREQ=MINUTELY;INTERVAL=10'
,end_date => NULL
,job_type => 'STORED_PROCEDURE'
,enabled => TRUE
,job_action => 'JOB_CLIENTES_FTP_IN'
,comments => 'Job que carrega os ficheiros de pre-aviso de cliente'
END;
ORA-01870: the intervals or datetimes are not mutually comparable
ORA-01426: numeric overflow
ORA-01426: numeric overflow
ORA-06512: at "SYS.DBMS_ISCHED", line 124
ORA-06512: at "SYS.DBMS_SCHEDULER", line 271
ORA-06512: at line 2
Edited by: cibernauta on Nov 4, 2010 12:48 PM -
Help with job scheduling; decode error
Hi
Iam trying to change a job that runs my procedure using dbms_job.. Here is the output I got.
Can someone help me why this is giving me errors.
<code>
SQL> exec dbms_job.next_date(395,decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),-1,'trunc(sysdate) +18.5/24',1,'trunc(sysdate)+1+6.5/24'));
BEGIN dbms_job.next_date(395,decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),-1,'trunc(sysdate) +18.5/24',1,'trunc(sysdate)+1+6.5/24')); END;
ERROR at line 1:
ORA-06550: line 1, column 30:
PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
statement only
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
</code>
Thanks in advanceI'm not sure what you're trying to achieve.
Is this a one time action or do you want to run this statement on a regular basis?
How about this:
begin
if ( to_number(to_char(sysdate,'hh24')) <= 17 ) then
dbms_job.next_date(395, 'trunc(sysdate)+18.5/24');
else
dbms_job.next_date(395, 'trunc(sysdate)+1+6.5/24');
end if;
end; -
Immediate help required with decode statement in scheduling jobs
Hi
Iam trying to change a job that runs my procedure using dbms_job.. Here is the output I got.
Can someone help me why this is giving me errors.
<code>
SQL> exec dbms_job.next_date(395,decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),-1,'trunc(sysdate) +18.5/24',1,'trunc(sysdate)+1+6.5/24'));
BEGIN dbms_job.next_date(395,decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),-1,'trunc(sysdate) +18.5/24',1,'trunc(sysdate)+1+6.5/24')); END;
ERROR at line 1:
ORA-06550: line 1, column 30:
PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL
statement only
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
</code>
Thanks in advanceA possible solution:
declare
v_next_varchar varchar2(30);
v_next_date date;
begin
select decode(sign(substr(to_char(sysdate,'dd/mm/yy hh24:mi'),10,2)-17),
-1,'trunc(sysdate) +18.5/24',
1,'trunc(sysdate) +1+6.5/24'
into v_next_varchar
from dual;
execute immediate 'select ' || v_next_varchar || ' from dual ' into v_next_date;
dbms_job.next_date(22, v_next_date);
commit;
end;Bye, Aron -
Suspending jobs scheduled in dba_jobs
Oracle9i
Hi: I have a few jobs scheduled as shown in the dba_jobs. I want to suspend some of the jobs for 2 days. Is there a way to suspend these jobs?
select JOB,INTERVAL from dba_jobs;
JOB INTERVAL
121 trunc(sysdate+1/24, 'HH24')
104 trunc(sysdate+1/12, 'HH24')+1/96
107 trunc(sysdate+1/24, 'HH24')+3/96
81 sysdate+1/12
108 trunc(sysdate+1/24, 'HH24')+3/96
186 trunc(sysdate+1/24, 'HH24')
110 trunc(sysdate+1, 'HH24')
206 trunc(sysdate+1/12, 'HH24')+1/96
181 sysdate+1
182 sysdate+1
183 sysdate+1
185 trunc(sysdate+1/24, 'HH24')
201 trunc(sysdate+1/12, 'HH24')+1/96
202 trunc(sysdate+1/12, 'HH24')+1/96
203 trunc(sysdate+1/12, 'HH24')+1/96
204 trunc(sysdate+1/12, 'HH24')+1/96
205 TRUNC(SYSDATE+1/12, 'HH24')+1/96
207 trunc(sysdate+1/12, 'HH24')+1/96
208 trunc(sysdate+1/12, 'HH24')+1/96
209 trunc(sysdate+1/12, 'HH24')+1/96
210 trunc(sysdate+1/12, 'HH24')+1/96
211 trunc(sysdate+1/12, 'HH24')+1/96
212 trunc(sysdate+1/12, 'HH24')+1/96If you know when you want it to start again, use something like this
begin
sys.dbms_job.NEXT_DATE( job => 1234,
next_date => TO_DATE( '13 Aug 2010 17:15:00', 'DD Mon YYYY HH24:MI:SS' ) );
end;
COMMIT;If you want it to not run until you decide to manually intervene, use something like this
begin
dbms_job.broken(job => 66
,broken => TRUE);
end;
commit; -
I am running my database on Oracle 8.1.5.0.0
I scheduled to excute this proceudre through DBMS_JOB
SQL> desc temp;
Name Null? Type
ID NUMBER
NAME VARCHAR2(25)
--Procedure referred in the DBMS_JOB.ISUBMIT procedure
CREATE OR REPLACE PROCEDURE TEMPPROCEDURE
AS
BEGIN
insert into temp values(1,'Hello');
COMMIT;
DBMS_JOB.NEXT_DATE(999,
last_day(SYSDATE)+1
END;
--Procedure to submit the job.
CREATE OR REPLACE PROCEDURE jobpro1
AS
v_what VARCHAR2(2000) := 'TEMPPROCEDURE;';
BEGIN
DBMS_JOB.ISUBMIT(999,
v_what,
SYSDATE,
null);
commit;
END;
It supposed to execute 1st of every month. That's why I need to change the job's next_date. I have initialized the following parameters in init.ora file....
job_queue_processes = 10
job_queue_interval = 10
job_queue_keep_connections = false
But it's not working. Is it needed to initialize any other
parameter to activate DBMS_JOB package or there is any wrong in my program.
Can any body help me regarding this.
thanks in advance
Shibashish NandaHi,
refer : Job Manager -
Hello,
I am having a problem with after update trigger. I have created an after update trigger in Oracle that would call a procedure to run an Oracle report. The problem is that when the report is run, the table is not updated yet. So the table passes old values to the report. Is there any way I can take care of this issue? How do I make sure the table is updated before running the report? I tried delaying the report by using dbms_job package. I didn't have any success with that. Probably I am doing something wrong. This is the code I used
dbms_job.submit( job => l_job, what => 'SendPDFReport(:new.query_id,serviceid,:new.site_id);', next_date => sysdate+3/24*60 );
Thanks
Oracle database UserIt is working. I used the same code,but I was using parameters inside the single quote, so it was taking the parameter value as :new.query_id instead of 12345.
I made changes
from
dbms_job.submit( job => l_job, what => 'SendPDF(:new.query_id,serviceid,:new.site_id);', next_date => sysdate);
to
dbms_job.submit( job => l_job, what => 'SendPDF('||:new.query_id||','||serviceid||','||:new.site_id||');', next_date => sysdate);
Thanks for all your help. -
How to add record to DBA_JOBS tables
Hi:
I would like to know how can I insert a new record to DBA_JOBS table ?
Thank you for your time!I want to assing following update statemtnet and schedule it.. Should I create a SP for this update (Ex: MY PROCEDURE), and then passs it to the dbms_job.submit ?
update rte_note set record_mode_code ='OFFICIAL'
where record_mode_code = 'WIP' and sys_create_time + 1 <=sysdate;
exec dbms_job.isubmit(784, 'MY PROCEDURE', SYSDATE); -
Hello Friends,
I wrote the database trigger which executes when the db is up but it's not happen and i'm not able to find out the exact problem that the trigger is not exceutin or the problem in the job which is written inside the trigger.
CREATE OR REPLACE TRIGGER FICREPORTS.trg_reporting
AFTER STARTUP ON DATABASE
WHEN (TO_CHAR (SYSDATE, 'D') <> '1')
DECLARE
v_currdate DATE := SYSDATE;
BEGIN
DBMS_JOB.isubmit (101,
'begin proc_reportingstatus; end;',
TO_CHAR (TRUNC(SYSDATE)+15/48,'dd-mon-rr hh:mi:ss') ,
TO_CHAR (TRUNC(SYSDATE+1)+15/48,'dd-mon-rr hh:mi:ss')
END trg_reporting;
Kindly help.
With Regards,
AnandI advice you to create a table and insert a row in it after BEGIN
CREATE TABLE test (ddate date);
and after begin :
BEGIN
INSERT INTO test VALUES(sysdate);
DBMS_JOB .....
If there'll be a row in the table test, then your trigger is working and you've problem in your job -
Hi every body ,
I configured my schedule push to
BEGIN
DBMS_DEFER_SYS.SCHEDULE_PUSH(
destination => 'orc1.mydomain.com',
interval => 'SYSDATE + (1/1440)',
next_date => SYSDATE,
parallelism => 1,
stop_on_error => FALSE,
delay_seconds => 0);
END;
to check that if my tables become updated every one minute and test the environment
but i don't know why it does not push it and i can still see that in oem(DBMS JOBS tab)
I did also check my links and also the timing on that is periodic and have been set.
my job_queue_process is also equal to 10
I would be grateful if you help me.
Mery
Edited by: user643323 on Sep 10, 2008 4:48 PMThanks for the quick respond and follow up
well why purge I thought it should be propagated with schedule_push as I read the below paragraph in book:
" At scheduled intervals or on-demand, the deferred transactions in the deferred
transaction queue are propagated to the target destinations. Each destination
may have a different interval."
and purge just remove the successfully pushed transaction after the designated time as I read the below paragraph:
"When a deferred transaction has been successfully pushed to all remote master
sites, it is not purged from the deferred transaction queue at the originating site
immediately. It may be purged later by a purge job, which runs at a
user-defined interval."
So why a setting lazy purge (because i set in for every one day)makes problem?Shouldn't it be propagated with schedule push?
When i insert 1 record schedule_push works but for 16000 bulk insert it doesn't??!!!!!!
Thank you
Mery
Edited by: user643323 on Sep 12, 2008 10:00 AM
Edited by: user643323 on Sep 12, 2008 10:01 AM
Edited by: user643323 on Sep 12, 2008 10:01 AM -
SYS.BSLN_MAINTAIN_STATS_JOB change time...
Hello all,
i am on 11.2 and there is a job called SYS.BSLN_MAINTAIN_STATS_JOB which runs at midnight. I was trying to figure out a way to change the time for this as this is conflicting with one of our other jobs and need to change the time....i tried looking in to doc but looks like this is not a straight forward process compared to job schedule by us (dba_jobs).... any help on this would be appericaited...try using DBMS_JOB.NEXT_DATE
exec DBMS_JOB.NEXT_DATE(job#,to_date('11/08/2011 18:00','DD/MM/YYYY HH24:MI'))
replace the job# with the job id from the dba_jobs table and change the time that suits you.
oracle document for the dbms_job http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_job.htm
Edited by: user476341 on Aug 11, 2011 5:54 PM
Maybe you are looking for
-
How to restore time machine backup without disturbing already installed app
Hi! My school recently reconfigured/reformatted my macbook and install the school image. Now it is filled with applications that the school help us installed. Now how do i restore the backup that my time machine backups last time? Migration assistant
-
What steps do I need to take when upgrading to a new hardrive(sofware,etc)?
-
I have called 5 times and Verizon will not come and move their line. it is running directly over my house, which needs to be raised as it is in a flood zone and was damaged by sandy. No one at Verizon cares.
-
Unable to successfully download Production Premium CS5.5
Hello I am using a corporate broadband network and have tried for 3 days and 2 nights to download Production Premium CS5.5 for Mac (the main installer which is 8.8 GB). We purchased 4 licenses, but I'm unable to download the installer. Friday, I left
-
JavaScript: How to check if a file exists.
Hello Everybody, Can you tell me how to check if a file exists using JavaScript and Internet Explorer. Browsing on this website I could read about the command "f.exists()" and it was necessary to include "java.io.*". Should I use this same command an