在dbms_utility工具包中,有一个函数get_time
get_time function: This function findd out the current time in 100th's second. It's primarily useful for delemining elasped time.
Syntax: dbms_utility.get_time
return number;
Returns: Time is the number of 100th's of a second from som arbitrary epoch.
实例:
我在过程里休眠了2秒,测试一下用dbms_utility.get_time 估算的时间
测试过程:
SQL> select * from v$version;
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL>
SQL> create or replace procedure toms_test as
2 v_i int;
3 v_j int;
4 begin
5 select dbms_utility.get_time into v_i from dual;
6 dbms_lock.sleep(2);
7 select dbms_utility.get_time into v_j from dual;
8 dbms_output.put_line('开始='||v_i||' 结束='||v_j||' 时间差='||to_char(v_j-v_i)/100);
9 end;
10 /
过程已创建。
SQL> set serveroutput on
SQL> exec toms_test;
开始=696256 结束=696456 时间差=2
PL/SQL 过程已成功完成。
SQL>