标签:
創建表
CREATE TABLE PROCESS_TIMING_LOG
(
PROCESS_NAME VARCHAR2(50 BYTE),
EXECUTION_DATE DATE,
RECORDS_PROCESSED NUMBER,
ELAPSED_TIME_SEC NUMBER
)
創建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;
/
運行結果
PROCESS_NAME,EXECUTION_DATE,RECORDS_PROCESSED,ELAPSED_TIME_SEC
update_salary,2016/8/1 下午 02:57:08,4257554,532.28
标签:
原文地址:http://www.cnblogs.com/guilingyang/p/5727009.html