如何理解 dbms_utility.get_time()

[复制链接]
查看11 | 回复9 | 2008-6-30 12:48:39 | 显示全部楼层 |阅读模式
This function finds out the current time in 100th's of a second. It is primarily useful for determining elapsed time.
Syntax
DBMS_UTILITY.GET_TIME
RETURN NUMBER;
Returns
Time is the number of 100th's of a second from some arbitrary epoch.
我的理解是返回当前时间的1/100秒,但是它是和什么时间对比呢
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
v_start := DBMS_UTILITY.GET_TIME/100
do things
v_end := DBMS_UTILITY.GET_TIME/100
它是以前后两个取点做对比的...
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
UP
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
最初由 xzh2000 发布
[B]v_start := DBMS_UTILITY.GET_TIME/100
do things
v_end := DBMS_UTILITY.GET_TIME/100
它是以前后两个取点做对比的... [/B]

做对比可以求出运行的时间,可是DBMS_UTILITY.GET_TIME的返回值也应该有具体的意思吧,请大师指教
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
最初由 oradbHome 发布
[B]
做对比可以求出运行的时间,可是DBMS_UTILITY.GET_TIME的返回值也应该有具体的意思吧,请大师指教 [/B]

单个是没有具体意义的,就是用来取差值的!
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
最初由 oradbHome 发布
[B]
做对比可以求出运行的时间,可是DBMS_UTILITY.GET_TIME的返回值也应该有具体的意思吧,请大师指教 [/B]

真的硬要说意义,那就是经过多次比较后发现跟折算成时分秒小数秒,跟systimestamp的时分秒小数秒有一个固定的差。
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
最初由 battleman 发布
[B]
单个是没有具体意义的,就是用来取差值的! [/B]

是的
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
谢谢大家的回复
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
GET_TIME
回复

使用道具 举报

千问 | 2008-6-30 12:48:39 | 显示全部楼层
Stanley -- Thanks for the question regarding "DBMS_UTILITY.GET_TIME", version 9i
Submitted on 5-Jan-2002 12:29 Eastern US timeTom's latest followup | Bookmark | BottomLast updated 25-Apr-2007 13:27
You Asked
Hi Tom,
Earlier in Oracle 7.3.4 the return value from DBMS_UTILITY.GET_TIME was positive
number but when i tried in Oracle 9i am getting a negative value.
SQL>ed gettime
Set Serveroutput On
Declare
nTemp Number(12);
Begin
nTemp := Dbms_Utility.Get_Time;
Dbms_Output.Put_Line(nTemp);
End;
/
SQL> sta gettime
-2065910589
Is this how the return value should be or is there any problem?
Thanks in Advance
Regards
Stanley

and we said...
Its OK, as it's only useful for measuring elapsed time.
[email protected]> exec dbms_output.put_line( dbms_utility.get_time );
-2051479853
PL/SQL procedure successfully completed.
[email protected]> variable n number
[email protected]> exec :n := dbms_utility.get_time
PL/SQL procedure successfully completed.
[email protected]> exec dbms_lock.sleep( 1 )
PL/SQL procedure successfully completed.
[email protected]> exec dbms_output.put_line( dbms_utility.get_time - :n );
108
PL/SQL procedure successfully completed.

so it still works in that capacity.
If you don't like it being "negative" (its a function of the machine clock and CAN be
observed in 8/7.x as well), you can add power(2,32) to the number.Here is an example
from 806 showing it can (and will) be negative (it'll EVENTUALLY go positive again, we
put it into a 32 bit signed integer, it rolls over, goes negative then goes to zero and
goes back up)
[email protected]> exec dbms_output.put_line( dbms_utility.get_time );
-2051457232
PL/SQL procedure successfully completed.
[email protected]> variable n number
[email protected]> exec :n := dbms_utility.get_time
PL/SQL procedure successfully completed.
[email protected]> exec dbms_lock.sleep( 1 )
PL/SQL procedure successfully completed.
[email protected]> exec dbms_output.put_line( dbms_utility.get_time - :n );
101
PL/SQL procedure successfully completed.
[email protected]>
[email protected]>
[email protected]>
[email protected]> exec dbms_output.put_line( dbms_utility.get_time+power(2,32));
2243510166
PL/SQL procedure successfully completed.
[email protected]> variable n number
[email protected]> exec :n := dbms_utility.get_time+power(2,32)
PL/SQL procedure successfully completed.
[email protected]> exec dbms_lock.sleep( 1 )
PL/SQL procedure successfully completed.
[email protected]> exec dbms_output.put_line( (dbms_utility.get_time+power(2,32)) -
:n );
101
PL/SQL procedure successfully completed.
If you are UNLUCKY enough to hit it when it rolls- you'll get weird timings (been there,
done that)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行