使用类型为SYS_refcursor的输出参数 [英] Using ouput parameter of type SYS_refcursor

查看:505
本文介绍了使用类型为SYS_refcursor的输出参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的数据库中,我有一个存储过程,其输出参数的类型为SYS_REFCURSOR.应用程序端使用C#编写.我可以将此过程的输出参数分配给数据表吗?

In my database I have a stored procedure with an OUTPUT parameter of type SYS_REFCURSOR. The application side is wrtitten in C#. Can I assign this procedure's output parameter to a Datatable like:

 .............
 OracleConnection con=new OracleConnection(......);
 OracleCommand cmd=new OracleCommand("MyStoredProc",con);
 cmd.CommandType=CommandType.StoredProcedure;
 cmd.Parameters.Add("REC_CUR",OracleType.Cursor).Direction=ParameterDirection.Output;
 con.Open();
 cmd.ExecuteNonQuery();
 DataTable dt=(DataTable)cmd.Parameters["REC_CUR"].value;//is this legal?

推荐答案

以下是我自己的问题的答案.如果存储过程的输出参数的类型为SYS_REFCURSOR,则命令

Here's the answer to my own question. If the output parametr of a stored procedure is of type SYS_REFCURSOR then the command

cmd.Parameters["REC_CUR"].value

将返回一个OracleDataReader对象,而不是一个表.而且,从OracledataReader到DataTable都没有隐式转换,也没有显式转换.

will return an OracleDataReader object, not a table. And there's no implicit , nor explicit cast from OracledataReader to DataTable.

这篇关于使用类型为SYS_refcursor的输出参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆