Home » SQL & PL/SQL » SQL & PL/SQL » trunc(sysdate + 1)
trunc(sysdate + 1) [message #10196] Thu, 08 January 2004 05:22 Go to next message
patrick
Messages: 83
Registered: December 2000
Member
I have a question. There is a job and i want it to run everyday at the same time at 1 am. I wrote the following script.

variable jobno number;
begin
dbms_job.submit (:jobno, 'jobname;', trunc(sysdate + 1) + 1/24);
commit;
end;

I am new in SQL so i have the problem of running only once. Tomorrow at 1 am. Can someone help me?

Thank you very much
Re: trunc(sysdate + 1) [message #10197 is a reply to message #10196] Thu, 08 January 2004 06:02 Go to previous messageGo to next message
sverch
Messages: 582
Registered: December 2000
Senior Member
What problem did you have?
Re: trunc(sysdate + 1) [message #10201 is a reply to message #10196] Thu, 08 January 2004 09:31 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You did not include the interval parameter, so the job only runs once:

dbms_job.submit (:jobno, 'jobname;', trunc(sysdate + 1) + 1/24, <b>'trunc(sysdate + 1) + 1/24'</b>);
Re: trunc(sysdate + 1) [message #10215 is a reply to message #10201] Thu, 08 January 2004 21:36 Go to previous messageGo to next message
patrick
Messages: 83
Registered: December 2000
Member
Thank you very much for the answer.

Patrick. I'll try it today and let you know
Re: trunc(sysdate + 1) i don't get it [message #10216 is a reply to message #10201] Thu, 08 January 2004 21:54 Go to previous messageGo to next message
patrick
Messages: 83
Registered: December 2000
Member
I used the command but i don't really understand the last part. I understand the sysdate + 1 that means he has to repeat it the following day. But why do i have to put 1/24 behind it again?

when i lookup the result i see the following

JOB NEXT_DATE NEXT_SEC SUBSTR(WHAT,1,35)
---------- --------- -------- -----------------------------------
INTERVAL
--------------------------------------------------------------------------------
6 10-JAN-04 02:00:00 jobname;
trunc(sysdate + 1) + 1/24

Is it correct that it will start on 10-JAN at 2 AM. and then on 11 jan at 2 am? I am not sure.

thank you for answering

Patrick
Re: trunc(sysdate + 1) i don't get it [message #10217 is a reply to message #10216] Thu, 08 January 2004 23:13 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
If your internval were just 'sysdate + 1' then it would run again one day (24 hours) after the time that the previous job finished. So, if the previous job started at 01:00 and it took 5 minutes to run, finishing at 01:05, then it would start at 01:05 the next day. We use trunc to avoid this sliding job problem. If your internval were just trunc(sysdate) + 1, then the job would begin at 00:00 the next day, regardless of the time of your previous run. If you want it to run at 01:00, then you need to add one hour (1/24 of a day): trunc(sysdate) + 1 + 1/24.
I think i understand it [message #10228 is a reply to message #10217] Fri, 09 January 2004 02:35 Go to previous message
patrick
Messages: 83
Registered: December 2000
Member
Will be testing it this weekend and i will see the results on monday. Looks really good.

Thank you very much for the explenation
Previous Topic: How to query a record like 'C&C5282'
Next Topic: solution please
Goto Forum:
  


Current Time: Wed Apr 24 09:53:24 CDT 2024