熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ADO.NET訪問Oracle 9i存儲過程(上)[7]

2013-11-13 11:01:38  來源: .NET編程 

  以下代碼摘自上述包規范的包正文說明了 GetLocations 包中的第一個過程的實現細節

CREATE OR new PACKAGE BODY CRUD_LOCATIONS AS

  PROCEDURE GetLocations (cur_Locations OUT T_CURSOR)

  IS

  BEGIN

  OPEN cur_Locations FOR

  SELECT * FROM LOCATIONS;

  END GetLocations;

   Implementation of other procedures ommitted

  END CRUD_LOCATIONS;

  使用 DataReader

  可以通過調用 OracleCommand 對象的 ExecuteReader() 方法來創建 OracleDataReader本節說明如何使用 DataReader 來訪問由存儲過程 SELECT_JOB_HISTORY 返回的結果集以下為包規范

CREATE OR new PACKAGE SELECT_JOB_HISTORY AS

  TYPE T_CURSOR IS REF CURSOR;

  PROCEDURE GetJobHistoryByEmployeeId

  (

  p_employee_id IN NUMBER

  cur_JobHistory OUT T_CURSOR

  );

  END SELECT_JOB_HISTORY;

  包正文定義了一個過程該過程檢索指定員工的工作經歷的結果集並將其作為 REF CURSOR 輸出參數返回

CREATE OR new PACKAGE BODY SELECT_JOB_HISTORY AS

  PROCEDURE GetJobHistoryByEmployeeId

  (

  p_employee_id IN NUMBER

  cur_JobHistory OUT T_CURSOR

  )

  IS

  BEGIN

  OPEN cur_JobHistory FOR

  SELECT * FROM JOB_HISTORY

  WHERE employee_id = p_employee_id;

  END GetJobHistoryByEmployeeId;

  END SELECT_JOB_HISTORY;

[]  []  []  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/15007.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.