Home » SQL & PL/SQL » SQL & PL/SQL » get elapsed time for a sql into plsql
get elapsed time for a sql into plsql [message #127799] Wed, 13 July 2005 07:38 Go to next message
xaelizious
Messages: 2
Registered: July 2005
Junior Member
I need calculate elapsed time for sql sentences into plsql, like timing in sqlplus, for insert the time into table. In Oracle version 8i.
I search for execute immediate o dbms_sql but no one offer a way to know it.
Somebody know a way to make this.
Re: get elapsed time for a sql into plsql [message #127818 is a reply to message #127799] Wed, 13 July 2005 09:08 Go to previous messageGo to next message
Frank Naude
Messages: 4596
Registered: April 1998
Senior Member
Try this:

SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
  2     start_time BINARY_INTEGER;
  3     stop_time  BINARY_INTEGER;
  4  BEGIN
  5     start_time := DBMS_UTILITY.GET_TIME;
  6     -- Do stuff...
  7     stop_time := DBMS_UTILITY.GET_TIME;
  8     DBMS_OUTPUT.PUT_LINE('Time taken = '||TO_CHAR(stop_time - start_time));
  9  END;
 10  /
Time taken = 0

PL/SQL procedure successfully completed.


Best regards.

Frank
Re: get elapsed time for a sql into plsql [message #127933 is a reply to message #127818] Thu, 14 July 2005 04:01 Go to previous message
xaelizious
Messages: 2
Registered: July 2005
Junior Member
THX, it's the best way to get it.

Thanks again.
Previous Topic: how to do statistic not using query builder but by PL/SQL
Next Topic: fileopen fails...
Goto Forum:
  


Current Time: Fri Jul 18 08:38:57 CDT 2025