Oracle question regarding dbms_utility.get_time()

b4u

Golden Member
Nov 8, 2002
1,380
2
81
Hi,

Let's say I run this 2 SQL queries against an Oracle 10g Database, and retrieve the following results:

Query: select to_char(SYSDATE, 'YYYYMMDD_HHMISS') from dual;
Result: 20051213_102533

Query: select dbms_utility.get_time() from dual;
Result: 120792861

They are run in sequence, so I guess the millisecond can be the same, or have at least a maximum 2 milliseconds difference (although the first query doesn't have more precision than seconds, and so there may be a second difference at max).

Now my question is: dbms_utility.get_time() gives me the time in 100ths of seconds, but I thought it would be related to 0:00AM ... but I guess it is not ... so what are the results related to?
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
My guess is that get_time() is not inherently useful when used just once. Used twice, and it can provide decent performance measurement.

DECLARE
....v_timeelapsed, v_starttime;

BEGIN
....v_starttime := dbms_utility.get_time();

....-- Execute some query or set of queries

....v_elapsedtime := dbms_utility.get_time() - v_starttime;

END
 

boran

Golden Member
Jun 17, 2001
1,526
0
76
in java it is since 1970 or something. same in VB.Net so I guess it's a standard of some sorts. but yes for measuring what yime you're at right now it's pretty useless. I only use it for elapsed-time calculation.
 

b4u

Golden Member
Nov 8, 2002
1,380
2
81
I don't want to use it to get the current time, or anything like that ... I want to use it to create some sort of "primary identifier".

If it starts counting on a specific day 1, month 1 of an year (say 1970), I can use it independently, if it is not, then I would have to concat with the current date (some sort of "YYYYMMDD + dbms_utility.get_time()"). And although I'm using Oracle, I don't want to use sequences to create unique values. I'm looking for something more like a timestamp (in char format).

Thanks for the help :)