c#使用oracle存储过程获取结果集实例
2008-05-04 10:14
513 查看
存储过程:
create or replace PACKAGE FIRSTPAGE AS
/* TODO enter package declarations (types, exceptions, methods etc) here */
type v_cursor is REF CURSOR;
procedure getnumber(re_cursor out v_cursor);
END FIRSTPAGE;
create or replace PACKAGE BODY FIRSTPAGE AS
procedure getnumber(re_cursor out v_cursor) AS
BEGIN
/* TODO implementation required */
open re_cursor for
select * from testable;
END getnumber;
END FIRSTPAGE;
C#代码:
public DataSet GetTableByProcedure()
{
OracleConnection con = new OracleConnection(_connectionString);
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "firstpage.getnumber";
OracleParameter sp = new OracleParameter("re_cursor", OracleType.Cursor);
sp.Direction = ParameterDirection.Output;
cmd.Parameters.Add(sp);
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
cmd.Dispose();
con.Close();
con.Dispose();
return ds;
}
create or replace PACKAGE FIRSTPAGE AS
/* TODO enter package declarations (types, exceptions, methods etc) here */
type v_cursor is REF CURSOR;
procedure getnumber(re_cursor out v_cursor);
END FIRSTPAGE;
create or replace PACKAGE BODY FIRSTPAGE AS
procedure getnumber(re_cursor out v_cursor) AS
BEGIN
/* TODO implementation required */
open re_cursor for
select * from testable;
END getnumber;
END FIRSTPAGE;
C#代码:
public DataSet GetTableByProcedure()
{
OracleConnection con = new OracleConnection(_connectionString);
OracleCommand cmd = new OracleCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "firstpage.getnumber";
OracleParameter sp = new OracleParameter("re_cursor", OracleType.Cursor);
sp.Direction = ParameterDirection.Output;
cmd.Parameters.Add(sp);
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
cmd.Dispose();
con.Close();
con.Dispose();
return ds;
}
相关文章推荐
- C#中使用Oracle存储过程返回结果集
- C#中使用反射获取结构体实例
- C#中使用反射获取结构体实例
- C#中使用反射获取结构体实例
- C#使用SOAP获取webservice实例解析
- C#使用SOAP获取webservice实例解析
- Javascript 使用ajax与C#获取文件大小实例详解
- 使用c#调用oracle存储过程获取存储过程参数信息
- C#中使用反射获取结构体实例
- C# 枚举使用和对应说明获取实例
- C#中使用反射获取结构体实例及思路
- C#使用SOAP获取webservice实例解析
- C#中使用SendMessage进行进程通信的实例
- 在vb中使用Iphlpapi.dll获取网络信息 第四章 第四节 实例二:探测到某个IP地址经过的路由列表
- [C#]获取最近在Windows上所使用的文件
- jQuery使用ajax跨域获取数据的简单实例
- C#创建windows服务搭配定时器Timer使用实例(用代码做,截图版)
- 在C#中使用WIA获取扫描仪数据(二、WIA Automation Layer)
- windows下使用C#获取特定进程网络流量
- C# 获取当前正在使用的网卡地址