Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2004, 01:30 AM
normanfung normanfung is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 13 normanfung User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
dbms_utility.get_time

It seems like dbms_utility.get_time is not giving me the correct time...?
SET TIMING ON;

DECLARE
i NUMBER :=0;
time1 NUMBER;
time2 NUMBER;
BEGIN
time1:=dbms_utility.get_time;
LOOP
i:=i+1;
DBMS_OUTPUT.PUT_LINE(i);
EXIT WHEN i>1000;
END LOOP;
time2:=dbms_utility.get_time;

DBMS_OUTPUT.PUT_LINE(time1);
DBMS_OUTPUT.PUT_LINE(time2);
DBMS_OUTPUT.PUT_LINE('time elapsed in ms: ' || (time2-time1) /100*1000 );
END;

The output of the above script:

...
...
997
998
999
1000
1001
862757
862757
time elapsed in ms: 0

PL/SQL procedure successfully completed.

Elapsed: 00:00:11.25

*** It seems like get_time is not returning the correct time... What's happenning? ***

THANKS in advance!

Reply With Quote
  #2  
Old October 21st, 2004, 08:59 AM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 22 h 25 m 53 sec
Reputation Power: 19
well, you're db is just that fast. I believe that the dbms_output is buffered so it doesn't actually slow the loop as you expected. I also got elapsed of 0 on the my fast server.

I tried it with a time based wait loop and it seems to work as expected.

example: this waits in the loop for 10 seconds

Code:
DECLARE
 i NUMBER :=0;
 time1 NUMBER;
 time2 NUMBER;
 waitDate date;
BEGIN
  time1:=dbms_utility.get_time;
  select sysdate+(1/24/60/60*10) into waitDate from dual;
  LOOP
    i:=i+1;
    EXIT WHEN sysdate >= waitDate;
  END LOOP;
  time2:=dbms_utility.get_time;

  DBMS_OUTPUT.PUT_LINE(time1);
  DBMS_OUTPUT.PUT_LINE(time2);
  DBMS_OUTPUT.PUT_LINE('time elapsed in ms: ' || (time2-time1) /100*1000 );
END;


Edit: I believe that the elapsed time reported by sql+ includes the time to display the buffered data.

Last edited by hedge : October 21st, 2004 at 09:04 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > dbms_utility.get_time


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway