Home » SQL & PL/SQL » SQL & PL/SQL » Time taken for script (10g / 9)
Time taken for script [message #314717] Thu, 17 April 2008 10:30 Go to next message
McLan
Messages: 36
Registered: April 2008
Member

I would like to know how to write sql scripts for below:
1.how much time taken to complete the sql script
2. I have varibale timenow=1, and would like to add 1 to timenow for every second

Could you please suggest me above two solutions?

Cheers,
McLan
Re: Time taken for script [message #314719 is a reply to message #314717] Thu, 17 April 2008 10:39 Go to previous messageGo to next message
ThomasG
Messages: 3212
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Just use dates and a little maths

SQL> set serverout on;
SQL>
SQL> DECLARE
  2
  3  v_start DATE;
  4  v_end   DATE;
  5
  6  BEGIN
  7
  8      v_start := SYSDATE;
  9      Dbms_Lock.sleep(10);
 10      v_end   := SYSDATE;
 11
 12      Dbms_Output.put_line('Start    : ' || To_Char(v_start ,'dd.mm.yyyy hh24:mi:ss'));
 13      Dbms_Output.put_line('End      : ' || To_Char(v_end   ,'dd.mm.yyyy hh24:mi:ss'));
 14      Dbms_Output.put_line('Duration : ' || Round((v_end - v_start) * 60 * 60 * 24));
 15  END;
 16  /
Start    : 17.04.2008 17:38:22
End      : 17.04.2008 17:38:32
Duration : 10

PL/SQL procedure successfully completed.
Re: Time taken for script [message #314724 is a reply to message #314717] Thu, 17 April 2008 10:55 Go to previous message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Check this link.

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_util.htm#i1002765

Regards

Raj
Previous Topic: please check the query
Next Topic: Display many rows in one row
Goto Forum:
  


Current Time: Wed Feb 12 00:41:05 CST 2025