關於Oracle預存程序測試

來源:互聯網
上載者:User

常規方式儲存測試資訊

建立相關資料表

建立資料表TestInfoLog,和序號SEQ_TestInfoLog

參考目前的目錄下的 TestInfoLog.sql ,運行這部分指令碼。

建立測試資訊儲存包

建立一個測試資訊儲存的 Package

參考目前的目錄下的 PKG_Test_Info.pck,編譯這個包。

具體例子

例子1

在一個PL/SQL塊中使用測試包來儲存測試資訊,參考目前的目錄下的 example1.sql

-- 簡單使用的一個例子,結果查詢

select * from TESTINFOLOG
  declare
  i integer :=1;
  begin
  PKG_Test_Info.clearAllLogInfo;
  PKG_Test_Info.setLogContext('匿名塊測試','無',1);
  PKG_Test_Info.logInfo('i=1');
  PKG_Test_Info.logInfo('當前日期='||To_char(sysdate,'yyyy-mm-dd'));
  end;

例子2

在一個預存程序中儲存測試資訊

參考目前的目錄下的Test_PKG_Test_Info.prc

---在預存程序中儲存測試資訊,結果查詢 select * from TESTINFOLOG

  create or replace procedure Test_PKG_Test_Info(p_Param1 int,
  p_Param2 int,
  p_儲存日誌資訊 int default 1) is
  begin
  if(p_儲存日誌資訊)=1 then
  PKG_Test_Info.clearAllLogInfo;
  PKG_Test_Info.setLogContext('預存程序測試', 'Test_PKG_Test_Info', 1);
  
  PKG_Test_Info.logInfo('p_Param1='||to_char(p_Param1)||',p_Param2='
  ||to_char(p_Param2));
  end if;
  end ;

卸載指令碼

參考 uninsall.sql ,如果需要卸載運行這個指令碼

其它的方式儲存測試資訊

Log4plsql的介紹

Log4plsql是一個open source的工具,是一個在Oralce PL/SQL 下實現的LOG架構。

Log4plsql 是基於log4J 演化得來的。

相關網站

http://log4plsql.sourceforge.net/

http://sourceforge.net/projects/log4plsql/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.