1

基本上我在一个过程中这样做:

DECLARE
 CURSOR r_cursor is SELECT * from imp_exp.results where code = 8223558 FOR  UPDATE OF c_timestamp;

 BEGIN

 FOR idx IN r_cursor LOOP
   --dbms_output.put_line(idx.sample_code);
   update imp_exp.results set c_timestamp = TO_DATE('10-MAY-99', 'DD-MON=YY')    
WHERE CURRENT OF r_cursor;

END LOOP;

END;

我怎样才能显示这花了多长时间?谢谢!

4

2 回答 2

5
set timing on
begin
  call_your_procedure;
end;

这将产生:

anonymous block completed
Elapsed: 00:00:05.524
于 2012-05-07T16:06:19.203 回答
2

您也可以选择使用DBMS_UTILITY.get_time

DECLARE
    CURSOR r_cursor IS
      SELECT *
      FROM   imp_exp.results
      WHERE  code = 8223558
      FOR UPDATE OF c_timestamp;
    v_start_time NUMBER;
    v_end_time   NUMBER;
BEGIN
    v_start_time := DBMS_UTILITY.get_time;

    FOR idx IN r_cursor LOOP
        --dbms_output.put_line(idx.sample_code);
        UPDATE imp_exp.results
        SET    c_timestamp = To_date('10-MAY-99', 'DD-MON=YY')
        WHERE  CURRENT OF r_cursor;
    END LOOP;

    v_end_time := DBMS_UTILITY.get_time;

    dbms_output.Put_line('Elapsed time in seconds: '
                         || (v_end_time - v_start_time ) / 100);
END; 
于 2012-05-08T08:06:22.790 回答