Home » SQL & PL/SQL » SQL & PL/SQL » sysdate issue
sysdate issue [message #153924] Wed, 04 January 2006 23:00 Go to next message
gautamvv
Messages: 254
Registered: June 2005
Senior Member
i take a simple example of sysdate


SQL> select to_char(sysdate,'HH:MI:SS'),TO_CHAR(SYSDATE+900/(24*60*60),'HH:MI:SS') FROM DUAL;

TO_CHAR( TO_CHAR(
-------- --------
10:24:29 10:39:29




this means, sysdate+900/(24*60*60) will add 15 minutes to

current time.

i used the same logic in a dbms_job procedure

SQL> SELECT TEXT FROM USER_SOURCE WHERE NAME='TEMPINS';

TEXT
---------------------------------------------------------------------
procedure tempins is
v_jn number;
begin
dbms_job.submit(v_jn,'myinm;',sysdate,'SYSDATE+900/(24*60*60)');
 COMMIT;
end;



the myinm pocedure is

procedure myinm
is
begin
  delete from tbl_inmacs1;
  insert into tbl_inmacs1(val_avg,val_min) select avg(val1),min(val1)
  from tbl_inmacs where name like 'A%';
  insert into tbl_inmacs1(val_avg_b,val_min_b) select avg(val1),min(val1)
  from tbl_inmacs where name like 'B%';
  commit;
 end;



but, when i insert into tbl_inmacs, changes are occuring in
tbl_inmacs1 in less then 10 seconds

my doubt is, when i am using to_char, i can see the difference
is 15 minutes(dual table) , then why is it that in the procedure, the same
formula is taking less than 10 seconds?

Re: sysdate issue [message #153944 is a reply to message #153924] Thu, 05 January 2006 01:17 Go to previous messageGo to next message
Frank Naude
Messages: 4596
Registered: April 1998
Senior Member
Please run this query and post the results:

SELECT job,
       to_char(last_date, 'DD-MON-YYYY HH24:MI:SS'),
       to_char(next_date,'DD-MON-YYYY HH24:MI:SS')
  FROM user_jobs
 WHERE ...
Re: sysdate issue [message #153949 is a reply to message #153924] Thu, 05 January 2006 01:31 Go to previous messageGo to next message
gautamvv
Messages: 254
Registered: June 2005
Senior Member

 1  SELECT job,
 2         to_char(last_date, 'DD-MON-YYYY HH24:MI:SS') as "last date",
 3         to_char(next_date,'DD-MON-YYYY HH24:MI:SS') as "next date"
 4*   FROM user_jobs
QL> /

     JOB last date            next date
-------- -------------------- --------------------
      21 05-JAN-2006 13:02:30 05-JAN-2006 13:02:40





Re: sysdate issue [message #153954 is a reply to message #153924] Thu, 05 January 2006 01:43 Go to previous messageGo to next message
gautamvv
Messages: 254
Registered: June 2005
Senior Member
ok,



SQL> select job from user_jobs;

      JOB
---------
       21

SQL> select interval from user_jobs where job=21;

INTERVAL
------------------------------------------------------
sysdate+(10/(24*60*60))





before discovering or calculating this 15 minutes thing, i
experimented with 10 seconds...when it was a success, i
only changed the time in the procedure 'tempins'

so now that change is not reflected at interval column..

can i update this interval column?

or

can i say delete from user_jobs, and drop the procedure
and create afresh?


Re: sysdate issue [message #153955 is a reply to message #153949] Thu, 05 January 2006 01:48 Go to previous messageGo to next message
Frank Naude
Messages: 4596
Registered: April 1998
Senior Member
Try the following:

exec dbms_job.remove(21);
exec tempins;
Re: sysdate issue [message #153964 is a reply to message #153955] Thu, 05 January 2006 03:03 Go to previous messageGo to next message
tarundua
Messages: 1080
Registered: June 2005
Location: India
Senior Member

Just curious ,

What if you try the following -- (SYSDATE + 1/96)


SQL> select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS') ,to_char
(sysdate+1/96, 'DD-MON-YYYY HH24:MI:SS') from dual;

TO_CHAR(SYSDATE,'DD-MON-YYYYH TO_CHAR(SYSDATE+1/96,'DD-MON-
----------------------------- -----------------------------
05-JAN-2006 14:32:26          05-JAN-2006 14:47:26

Re: sysdate issue [message #153983 is a reply to message #153924] Thu, 05 January 2006 04:18 Go to previous messageGo to next message
gautamvv
Messages: 254
Registered: June 2005
Senior Member
@FrankNaude It works fine now, now that i removed the job
and submitted again

but again, there is a small problem, i have to type

"commit" at sqlplus for this procedure to run every 15 minutes,

i need to give this procedure to my java team, who will call

this from their code( i dont know how)..

if i dont give "commit" at sqlplus, the procedure is not
running for every 15 minutes...

how to make it to run every 15 mins, without giving commit
at sqlplus?

@tarun: yes, sysdate+1/96 works too, i know sysdate+1/24 is
one hour, how could u get that sysdate+1/96 is for 15 mins?
Re: sysdate issue [message #153987 is a reply to message #153983] Thu, 05 January 2006 04:36 Go to previous message
tarundua
Messages: 1080
Registered: June 2005
Location: India
Senior Member


Its simple mathematics.

1 -- 1 day

1/24 -- 1 hr

1/48 -- 1/2 hr

1/96 -- 15 mins
Previous Topic: dbms_redefinition.can_redef_table ('SAPR3','/abc/def');
Next Topic: Problem executing procedure
Goto Forum:
  


Current Time: Mon Sep 01 06:05:09 CDT 2025