Akshay Trivedi
Akshay Trivedi

Reputation: 49

Oracle DBMS_UTILITY.GET_TIME

Question : Why we divide the difference by 100 to get the time in seconds?

Start
Get current time(Start Time)
Perform logical transaction
Get current time(End Time)
Subtract End Time – Start Time
Divide it by 100 to get total time in seconds. (Why 100?)
Stop

Try Below code:

declare START_TIME PLS_INTEGER;
begin

    START_TIME := DBMS_UTILITY.GET_TIME;
    DBMS_OUTPUT.PUT_LINE('START_TIME-->'|| START_TIME);

    dbms_lock.sleep(10);
    DBMS_OUTPUT.PUT_LINE('DBMS_UTILITY.GET_TIME-->'|| DBMS_UTILITY.GET_TIME);
    DBMS_OUTPUT.PUT_LINE('execution time --> ' || (dbms_utility.get_time - start_time)/100);
end;

Upvotes: 0

Views: 7458

Answers (1)

GMB
GMB

Reputation: 222542

From the documentation (emphasis is mine):

This function determines the current time in 100th's of a second. This subprogram is primarily used for determining elapsed time. The subprogram is called twice – at the beginning and end of some process – and then the first (earlier) number is subtracted from the second (later) number to determine the time elapsed.

So you are dividing by 100 to get the duration of the procedure in seconds instead of hundredths of seconds.

Upvotes: 5

Related Questions