惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - culturenet

jQuery Mobile 小问题解决一例 flash的传值问题 Oracle 升级以后 HTTP Server 一则小错误解决 installshield安装文件的制作小技巧--附加数据库 使用installshild解决某些安装文件无法在win2003上安装的问题 vsta下vs2005产生错误,解决之 Test Windows Live Write (Bate) Gridview中当设置自动生成列时对列中字段使用 html代码显示 修改ppt另存为网页的mht文件内容,更改其显示方式 修改OleDB provider 移植 Data Application Blocks项目中使用存储过程的应用(Oracle or MsSqlServer)到Microsoft Access Enterprise Library- Data Block 使用MS Access的问题的解决 Oracle Services For Microsoft Transaction Server的问题的发现与解决 LinkButton 的提交两次问题的解决 Enterprise Library- Data Block使用oracle存储过程,字符串参数传入值为""时出现问题的解决 web.config中的pageBaseType问题 修改客户端Script,解决r.a.d.controls Q2 2005中TreeView 控件遮挡问题 [导入]汉字区位码查询 [导入]c#取得汉字的拼音的首字母。 [导入]url传递中文的解决方案总结 [导入]转:url传递中文的解决方案总结
Enterprise Library - Data Block oracle返回 cursor 问题的解决
culturenet · 2005-09-12 · via 博客园 - culturenet

          昨天使用 Data Block 操作 oracle 返回 cursor 。期间产生了一点问题,很是郁闷,找了一下午也没有解决。早上睡不着,起来继续找。结果找到了解决的方法。其实也是怪自己没有很好的看文档。在此记录一下。以使别的同志再出现我的问题的时候,很容易的找到解决的方法。

         问题是这样的:
   我在oracle里面有这样一个过程

ORA-06550: 第 1 行, 第 7 列: PLS-00306: 调用 'LISTALLSTATIC_USERS' 时参数个数或类型错误 ORA-06550: 第 1 行, 第 7 列: PL/SQL: Statement ignored

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.OracleClient.OracleException: ORA-06550: 第 1 行, 第 7 列: PLS-00306: 调用 'LISTALLSTATIC_USERS' 时参数个数或类型错误 ORA-06550: 第 1 行, 第 7 列: PL/SQL: Statement ignored

源错误:

行 44: 			
行 45: 			 DataSet dsCustomers = db.ExecuteDataSet(dbCommandWrapper);
行 46: DataGrid1.DataSource=dsCustomers; 行 47: DataGrid1.DataBind();

我以为是我的参数没有弄对,于是就加了一句:

dbCommandWrapper.AddOutParameter("cur_Static_User",DbType.Object,500);

结果还是一样的。后来也试验了

OracleCommandWrapper.AddParameter(string,DbType,int,ParameterDirection,bool,byte,byte,string,DataRowVersion,object);

这个方法来添加,也是不行。

后来就上网找了很长时间也没有什么进展。今天早上起来,还是一筹莫展,偶尔的打开Enterprise Library安装目录的Enterprise Library Release Notes.rtf文件,发现里面有这么一段

2.4 Data Access Application Block: Default Oracle cursor cur_OUT

The managed provider for Oracle requires you to explicitly bind your reference cursor in your parameter collection. This means you must explicitly create an output parameter for the cursor in your application code. However, that code will not be portable with database systems that do not require a parameter for the cursor. The OracleDatabase allows you to create commands without specifying a cursor. It will create a cursor, named cur_OUT, for commands that execute a stored procedure and do not include an output parameter for the cursor. This means that you can name your reference cursor as "cur_OUT" and the Data Access Application Block will bind it for you; you do not need to explicitly create an output parameter for the cursor. If your stored procedures use a cursor with a name other than "cur_OUT," you must explicitly add a parameter for each cursor to the command. Similarly, if your stored procedure contains multiple cursors, you must explicitly add each cursor parameter to the command.
这下我就明白了。在我的oracle函数中,我的名字 cur_Static_User 和默认的名字cur_OUT不匹配。于是我就改了我的存储过程的参数名称,cur_Static_User改为 cur_OUT。

问题就解决了。

经过试验,也可以用如下方法用自己的参数名,而不用默认的参数名。
也可以,在一个

PROCEDURE中返回多个 CURSOR我的存储过程:

代码如下:

Database db = DatabaseFactory.CreateDatabase("oraserver");
string sqlCommand = "Static_UserPackage.STATIC_USER_SelectAll";
Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleCommandWrapper dbCommandWrapper 
=(Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleCommandWrapper)db.GetStoredProcCommandWrapper(sqlCommand);
dbCommandWrapper.AddParameter(
"cur_OUT_f", OracleType.Cursor, 0, ParameterDirection.Output, true00, String.Empty, DataRowVersion.Default, Convert.DBNull);
dbCommandWrapper.AddParameter(
"cur_OUT_g", OracleType.Cursor, 0, ParameterDirection.Output, true00, String.Empty, DataRowVersion.Default, Convert.DBNull);
DataSet dsCustomers 
= db.ExecuteDataSet(dbCommandWrapper);
DataGrid1.DataSource
=dsCustomers.Tables[0];
DataGrid1.DataBind();
DataGrid2.DataSource
=dsCustomers.Tables[1];
DataGrid2.DataBind();