儲存過程批量生成awr指令碼
DECLARE
l_snap_start NUMBER := 40078;
l_snap_end NUMBER := 40081;
l_dir VARCHAR2(50) := 'AWRTEST';
l_last_snap NUMBER := NULL;
l_dbid NUMBER := 2778659381;
l_file UTL_FILE.file_type;
l_file_name VARCHAR(50);
cursor cur_inum is SELECT instance_number FROM dba_hist_snapshot WHERE dbid = l_dbid GROUP BY instance_number ORDER BY instance_number;
BEGIN
for l_instance_number in cur_inum loop
l_last_snap := NULL;
FOR cur_snap IN (SELECT snap_id
FROM dba_hist_snapshot
WHERE instance_number = l_instance_number.instance_number
AND snap_id BETWEEN l_snap_start AND l_snap_end
ORDER BY snap_id)
LOOP
IF l_last_snap IS NOT NULL THEN
l_file := UTL_FILE.fopen(l_dir, 'awr_' ||l_instance_number.instance_number||'_'|| l_last_snap || '_' || cur_snap.snap_id || '.html', 'w', 32767); --40162
FOR cur_rep IN (SELECT output
FROM TABLE(DBMS_WORKLOAD_REPOSITORY.awr_report_html(l_dbid, l_instance_number.instance_number, l_last_snap, cur_snap.snap_id)))
LOOP
UTL_FILE.put_line(l_file, cur_rep.output);
END LOOP;
UTL_FILE.fclose(l_file);
END IF;
l_last_snap := cur_snap.snap_id; --40161
END LOOP;
end loop;
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE;
END;
l_snap_start NUMBER := 40078;
l_snap_end NUMBER := 40081;
l_dir VARCHAR2(50) := 'AWRTEST';
l_last_snap NUMBER := NULL;
l_dbid NUMBER := 2778659381;
l_file UTL_FILE.file_type;
l_file_name VARCHAR(50);
cursor cur_inum is SELECT instance_number FROM dba_hist_snapshot WHERE dbid = l_dbid GROUP BY instance_number ORDER BY instance_number;
BEGIN
for l_instance_number in cur_inum loop
l_last_snap := NULL;
FOR cur_snap IN (SELECT snap_id
FROM dba_hist_snapshot
WHERE instance_number = l_instance_number.instance_number
AND snap_id BETWEEN l_snap_start AND l_snap_end
ORDER BY snap_id)
LOOP
IF l_last_snap IS NOT NULL THEN
l_file := UTL_FILE.fopen(l_dir, 'awr_' ||l_instance_number.instance_number||'_'|| l_last_snap || '_' || cur_snap.snap_id || '.html', 'w', 32767); --40162
FOR cur_rep IN (SELECT output
FROM TABLE(DBMS_WORKLOAD_REPOSITORY.awr_report_html(l_dbid, l_instance_number.instance_number, l_last_snap, cur_snap.snap_id)))
LOOP
UTL_FILE.put_line(l_file, cur_rep.output);
END LOOP;
UTL_FILE.fclose(l_file);
END IF;
l_last_snap := cur_snap.snap_id; --40161
END LOOP;
end loop;
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.is_open(l_file) THEN
UTL_FILE.fclose(l_file);
END IF;
RAISE;
END;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12272958/viewspace-2150429/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【AWR】Oracle批量生成awr報告指令碼Oracle指令碼
- 轉貼:批量生成awr報告指令碼指令碼
- oracle批量生成日期字尾的表儲存過程程式碼Oracle儲存過程
- 將表資料生成SQL指令碼的儲存過程和工具SQL指令碼儲存過程
- 批量生成AWR
- 批量插入資料的儲存過程儲存過程
- 生成sql server2000物件建立指令碼的儲存過程(轉)SQLServer物件指令碼儲存過程
- sqlserver資料庫還原儲存過程指令碼SQLServer資料庫儲存過程指令碼
- 用儲存過程封裝awrrpt指令碼(四)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(三)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(二)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(一)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(五)儲存過程封裝指令碼
- 批量生成DDL指令碼指令碼
- 從系統檢視中生成儲存過程的單元測試指令碼的指令碼(供參考)儲存過程指令碼
- Oracle '批量'禁用外來鍵的儲存過程Oracle儲存過程
- 生成awr報告的指令碼指令碼
- sqoop指令碼批量生成OOP指令碼
- Oracle 通過儲存過程來生成CSV檔案Oracle儲存過程
- 【AWR】自動生成AWR報告指令碼以及用法指令碼
- 自動生成對錶進行插入和更新的儲存過程的儲存過程 (轉)儲存過程
- MySQL儲存過程詳解 mysql 儲存過程MySql儲存過程
- 儲存過程儲存過程
- 指令碼:定時生成awr報告指令碼
- AWR報告自動生成指令碼指令碼
- 自動生成awr報告指令碼指令碼
- mssql sqlserver 批量刪除所有儲存過程的方法分享SQLServer儲存過程
- tcbs_批量儲存過程_sql_case when_示例儲存過程SQL
- 使用MyGeneration生成儲存過程和資料訪問層程式碼儲存過程
- SQL 儲存過程裡呼叫另一個儲存過程SQL儲存過程
- MySQL儲存過程詳解 mysql 儲存過程linkMySql儲存過程
- Oracle儲存過程乾貨(一):儲存過程基礎Oracle儲存過程
- awr報告每天自動生成指令碼指令碼
- JDBC 呼叫儲存過程程式碼示例JDBC儲存過程
- oracle儲存過程分頁程式碼Oracle儲存過程
- 儲存過程與儲存函式儲存過程儲存函式
- Oracle儲存過程Oracle儲存過程
- 使用儲存過程儲存過程