Use PL/SQL monitoring procedure to perform time

Source: Internet
Author: User

Create a table

CREATE TABLE Process_timing_log
(
Process_name VARCHAR2 (+),
Execution_date DATE,
records_processed number,
ELAPSED_TIME_SEC number
)

Creative procedure

CREATE OR REPLACE PROCEDURE scott.update_salary
As
CURSOR Cur_employee
Is
SELECT empno, Sal, ROWID from Employee_test;

Lv_new_salary_num number;
Lv_count_num Pls_integer: = 0;
Lv_start_time_num Pls_integer;
Lv_total_time_num number;
BEGIN
Lv_start_time_num: = dbms_utility. Get_time;

For Cur_employee_rec in Cur_employee
LOOP
Lv_count_num: = Lv_count_num + 1;
Lv_new_salary_num: = Cur_employee_rec.sal;

UPDATE Employee_test
SET sal= Lv_new_salary_num
WHERE ROWID = Cur_employee_rec. ROWID;
END LOOP;

Lv_total_time_num: = (dbms_utility. get_time-lv_start_time_num)/100;

INSERT into Process_timing_log (Process_name,
Execution_date,
Records_processed,
ELAPSED_TIME_SEC)
VALUES (' Update_salary ',
Sysdate,
Lv_count_num,
Lv_total_time_num);

COMMIT;
END update_salary;
/
The results of the exercise

Process_name,execution_date,records_processed,elapsed_time_sec
UPDATE_SALARY,2016/8/1 pm 02:57:08,4257554,532.28

Use PL/SQL monitoring procedure to perform time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.