C 呼叫ORACLE儲存過程返回結果集及函式

2021-05-25 16:06:20 字數 1944 閱讀 9823

文章出處:偉網動力

()有何見解,可以來此論壇

bbs/

轉貼請標明出處,謝謝。

有關.net

如何訪問

oracle

資料庫,在此就不介紹了。相關的資料也很多,有興趣的朋友可以看下文。

使用asp.net

訪問oracle

資料庫的方法

article/list.asp?id=649

oracle

的儲存過程返回記錄集,關鍵之處是要用游標。

關於資料庫的游標

(cursor)

大家肯定都接觸不少,我們可以通過

open,fetch,close

操作控制游標進行各種方便的操作,這方面的例子我就不在重複了。我們現在要介紹的是游標變數

(cursor variable)

。類似游標,游標變數也是指向乙個查詢結果集的當前行。不同的是,游標變數能為任何型別相似

(type-compatible)

的查詢開啟,而並不是繫結到某乙個特定的查詢。通過游標變數,你可以在資料庫的資料提取中獲得更多的方便。

首先是建立表。

create table lihuan.bill_points

(points_id number(10,0) not null,

customer_id number(10,0) not null,

bill_point_no number(2,0) default 1 not null,

constraint pk_bill_points primary key (points_id))/

其次,建

package

create or replace package lihuan.yy_pkg_bill_point_no/*

取得使用者的所有計費電序號

*/is

type t_cursor is ref cursor;

procedure bill_point_no(p_customer_id bill_points.customer_id%type,

re_cursor out t_cursor);

end;/

再次,建

package body

create or replace package body lihuan.yy_pkg_bill_point_no/*

取得使用者的所有計費電序號

*/is

procedure bill_point_no(p_customer_id bill_points.customer_id%type,

re_cursor out t_cursor)

isv_cursor t_cursor;

begin

open v_cursor for

select bill_point_no from bill_points where customer_id =p_customer_id;

re_cursor := v_cursor;

end;

end;/

最後,在

.net

中程式呼叫。

public dataset bill_point_no(string customer_id)//ok

else

return dataset;}

public bool runprocedure(string returnparameter,oracletype paramtype,ref dataset dataset,hashtable ht ,string procedurename,string oracleconnection)

oracledataadapter odadapter=new oracledataadapter(dacommand);

trycatch(system.exception e)

finally}

c 呼叫oracle儲存過程返回資料集

2008 12 20 10 59 57 分類 net 字型大小訂閱 create or replace package pkg tabletype istype tabletype is ref cursor procedure sp cpzd cpno in varchar2,status in ...

C 呼叫Oracle 儲存過程返回資料集 例項

1.在oracle 下建立表 t user id varchar 20 name varchar 20 2.新增資料 1 張三 2 李四 3.建立包並且定義變數和宣告儲存過程 create or replace package pkg user as 定義返回值 游標型別 type myrctype...

關於c 呼叫oracle儲存過程返回資料集的寫法

create or replace package body report.clinic rate asprocedure clinic master start date date,end date date,i number,t rate out t cursor is begin open t...