從系統檢視中生成儲存過程的單元測試指令碼的指令碼(供參考)
從系統檢視中生成儲存過程的單元測試指令碼(供參考)
[@more@]create or replace function f_get_proc_param(obj_name in varchar2)return varchar2 is
res varchar2(4000);
cnt number default 0;
begin
res := res || 'PROMPT **********************************************' || chr(10);
res := res || 'PROMPT Test ' || obj_name || chr(10);
res := res || 'PROMPT **********************************************' || chr(10);
res := res || 'PROMPT 模擬資料語句塊,請在此處新增SQL' || chr(10);
res := res || 'PROMPT ##############################################' || chr(10);
res := res || chr(10);
res := res || 'PROMPT 執行儲存過程,請修改引數值' || chr(10);
res := res || 'PROMPT ##############################################' || chr(10);
--res := res || 'DECLARE' || chr(10);
for rec in (select argument_name,
decode(data_type,'VARCHAR2','VARCHAR2(1000)',data_type) data_type,
in_out
from user_arguments
where object_name = obj_name
and in_out like '%OUT%'
and argument_name is not null) loop
res := res || 'VARIABLE ' || rec.argument_name || ' ' || rec.data_type || ';' || chr(10);
end loop;
--res := res || 'BEGIN' || chr(10);
res := res || 'EXEC ' || obj_name || '(' || chr(10);
for rec in (select argument_name,
data_type,
default_value,
default_length,
in_out
from user_arguments
where object_name = obj_name
and argument_name is not null
order by position) loop
if rec.in_out like '%OUT%' then
if cnt = 0 then
res := res || ' ' || rec.argument_name || ' => :' || rec.argument_name || chr(10);
else
res := res || ' ,' || rec.argument_name || ' => :' || rec.argument_name || chr(10);
end if;
else
if cnt = 0 then
res := res || ' ' || rec.argument_name || ' => ?' || chr(10);
else
res := res || ' ,' || rec.argument_name || ' => ?' || chr(10);
end if;
end if;
cnt := 1;
end loop;
res := res || ' );' || chr(10);
--res := res || ' DBMS_OUTPUT.PUT_LINE(''返回程式碼:"'' || V_AN_O_RET_CODE || ''"'');' || chr(10);
--res := res || ' DBMS_OUTPUT.PUT_LINE(''返回資訊:"'' || V_AC_O_RET_MSG || ''"'');' || chr(10);
--res := res || 'END;' || chr(10) || '/' || chr(10);
res := res || 'PROMPT 查詢結果,請在此處新增SQL' || chr(10);
res := res || 'PROMPT ##############################################' || chr(10);
res := res || chr(10);
return res;
end;
/
set feedback off
set head off
spool e:UnitTest.sql
select 'spool e:unittestTest'||a.object_name||'.sql' || chr(10) ||
'select ''' || f_get_proc_param(a.object_name) || ''' from dual;' || chr(10) ||
'spool off' script
from user_procedures a,user_objects b
where a.object_name = b.object_name
and b.object_type = 'PROCEDURE';
spool off
spool e:unittestmain.sql
prompt PROMPT 測試開始 ......
prompt PROMPT ==============================================
select script
from user_procedures a,user_objects b
where a.object_name = b.object_name
and b.object_type = 'PROCEDURE';
spool off
drop function f_get_proc_param;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/802415/viewspace-842460/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 儲存過程批量生成awr指令碼儲存過程指令碼
- 將表資料生成SQL指令碼的儲存過程和工具SQL指令碼儲存過程
- 我的測試儲存過程程式碼儲存過程
- 常用的Oracle指令碼參考Oracle指令碼
- 生成sql server2000物件建立指令碼的儲存過程(轉)SQLServer物件指令碼儲存過程
- pgbench 壓力測試指令碼作為參考.指令碼
- sqlserver資料庫還原儲存過程指令碼SQLServer資料庫儲存過程指令碼
- 用儲存過程封裝awrrpt指令碼(四)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(三)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(二)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(一)儲存過程封裝指令碼
- 用儲存過程封裝awrrpt指令碼(五)儲存過程封裝指令碼
- TCL指令碼語言在測試系統中的應用指令碼
- ORACLE儲存過程中建立子過程的測試!Oracle儲存過程
- 快速檢視LINUX 系統硬體的指令碼Linux指令碼
- 透過shell指令碼檢視procedure的資訊指令碼
- 透過shell指令碼檢視package的資訊指令碼Package
- 通過shell指令碼檢視procedure的資訊指令碼
- 通過shell指令碼檢視package的資訊指令碼Package
- rman儲存指令碼指令碼
- 系統巡檢指令碼指令碼
- 生成insert指令碼的指令碼指令碼
- unittest 單元測試框架教程 1-執行測試指令碼框架指令碼
- 單個過程獲取指令碼指令碼
- CentOS 6 系統優化檢測指令碼CentOS優化指令碼
- 儲存過程在主從庫上的測試儲存過程
- 在RFT中如何通過指令碼獲取已新增到某個指令碼中的測試物件?指令碼物件
- 檢視錶的統計資訊SQL指令碼SQL指令碼
- Linux系統效能測試指令碼(unixbenchnmon)Linux指令碼
- 檢視過去的session鎖情況指令碼Session指令碼
- 透過shell指令碼檢視鎖資訊指令碼
- 通過shell指令碼檢視鎖資訊指令碼
- 得到對錶操作的指令碼(可作為參考)指令碼
- 獲取單個檢視DDL指令碼指令碼
- rman的備份檢視的指令碼指令碼
- 檢測mysql狀態的指令碼MySql指令碼
- 檢視正在執行的儲存過程儲存過程
- SED單行指令碼快速參考(Unix 流編輯器)指令碼