知识大全 Enterprise Library-Data Block oracle

Posted

篇首语:莫问天涯路几重,轻衫侧帽且从容。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 Enterprise Library-Data Block oracle相关的知识,希望对你有一定的参考价值。

Enterprise Library-Data Block oracle  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

  昨天使用 Data Block 操作 oracle 返回 cursor 期间产生了一点问题 很是郁闷 找了一下午也没有解决 早上睡不着 起来继续找 结果找到了解决的方法 其实也是怪自己没有很好的看文档 在此记录一下 以使别的同志再出现我的问题的时候 很容易的找到解决的方法     问题是这样的     我在oracle里面有这样一个过程    PROCEDURE ListAllStatic_Users (cur_Static_User OUT T_CURSOR)  IS  BEGIN  OPEN cur_Static_User FOR  SELECT * FROM Static_User ;  END ListAllStatic_Users;    我在程序里面如下调用     Database db = DatabaseFactory CreateDatabase( oraserver );  string sqlCommand = Static_UserPackage ListAllStatic_Users ;  DBCommandWrapper dbCommandWrapper =db GetStoredProcCommandWrapper(sqlCommand);  DataSet dsCustomers = db ExecuteDataSet(dbCommandWrapper);  DataGrid DataSource=dsCstomers;  DataGrid DataBind();    结果出现如下问题     ORA : 第 行 第 列: PLS : 调用 LISTALLSTATIC_USERS 时参数个数或类型错误 ORA : 第 行 第 列: PL/SQL: Statement ignored    说明: 执行当前 Web 请求期间 出现未处理的异常 请检查堆栈跟踪信息 以了解有关该错误以及代码中导致错误的出处的详细信息     异常详细信息: System Data OracleClient OracleException: ORA : 第 行 第 列: PLS : 调用 LISTALLSTATIC_USERS 时参数个数或类型错误 ORA : 第 行 第 列: PL/SQL: Statement ignored    源错误:    行   行 DataSet dsCustomers = db ExecuteDataSet(dbCommandWrapper);行 DataGrid DataSource=dsCustomers;  行 DataGrid DataBind();    我以为是我的参数没有弄对 于是就加了一句     dbCommandWrapper AddOutParameter( cur_Static_User DbType Object );    结果还是一样的 后来也试验了    OracleCommandWrapper AddParameter(string DbType int ParameterDirection bool byte byte string DataRowVersion object);    这个方法来添加 也是不行     后来就上网找了很长时间也没有什么进展 今天早上起来 还是一筹莫展 偶尔的打开Enterprise Library安装目录的Enterprise Library Release Notes rtf文件 发现里面有这么一段     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 mands without specifying a cursor It will create a cursor named cur_OUT for mands 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 mand Similarly if your stored procedure contains multiple cursors you must explicitly add each cursor parameter to the mand     这下我就明白了 在我的oracle函数中 我的名字 cur_Static_User 和默认的名字cur_OUT不匹配     于是我就改了我的存储过程的参数名称 cur_Static_User改为 cur_OUT     问题就解决了     经过试验 也可以用如下方法用自己的参数名 而不用默认的参数名 也可以 在一个PROCEDURE中返回多个 CURSOR    我的存储过程     Procedure STATIC_USER_SelectAll  ( cur_OUT_f OUT T_OUT cur_OUT_g OUT T_OUT)  AS  Begin  OPEN cur_OUT_f FOR Select * from STATIC_USER;  OPEN cur_OUT_g FOR Select * from STATIC_ROLE;  End;    Procedure STATIC_USER_SelectAll  ( cur_OUT_f OUT T_OUT cur_OUT_g OUT T_OUT)  AS  Begin  OPEN cur_OUT_f FOR Select * from STATIC_USER;  OPEN cur_OUT_g FOR Select * from STATIC_ROLE;  End;    Procedure STATIC_USER_SelectAll  ( cur_OUT_f OUT T_OUT cur_OUT_g OUT T_OUT)  AS  Begin  OPEN cur_OUT_f FOR Select * from STATIC_USER;  OPEN cur_OUT_g FOR Select * from STATIC_ROLE;  End; 代码如下     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 ParameterDirection Output true String Empty DataRowVersion Default Convert DBNull);  dbCommandWrapper AddParameter( cur_OUT_g OracleType Cursor ParameterDirection Output true String Empty DataRowVersion Default Convert DBNull);  DataSet dsCustomers = db ExecuteDataSet(dbCommandWrapper);  DataGrid DataSource=dsCustomers Tables[ ];  DataGrid DataBind();  DataGrid DataSource=dsCustomers Tables[ ];  DataGrid DataBind(); cha138/Article/program/Java/hx/201311/25559

相关参考

知识大全 Enterprise Architecture 简介

EnterpriseArchitecture简介  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  

知识大全 Enterprise Library 4.0下载

EnterpriseLibrary4.0下载  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  En

知识大全 Oracle Enterprise Manager常见问题及解决

OracleEnterpriseManager常见问题及解决  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看

知识大全 Visual Studio .NET Enterprise Architect 中基于 Visio

VisualStudio.NETEnterpriseArchitect中基于Visio  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布

知识大全 用Solstice Enterprise Manager建立Java网络管理应用程序

用SolsticeEnterpriseManager建立Java网络管理应用程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容

知识大全 Oracle 9i 数据库管理实务讲座(一)-如何安装Oracle 9i Enterprise E

Oracle9i数据库管理实务讲座(一)-如何安装Oracle9iEnterpriseE  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发

整体风险管理的简介

Enterprise―wideRiskManagement,根据财产保险精算协会(cAs)定义:“公司整体风险管理是公司用以评估、控制、利用、应对、监控所有那些可能影响公司相关方的长短期价值的风险的流

什么是全面风险管理理念?

全面风险管理理念(Enterprise-wideRiskManagement,简称ERM)侧重通过公司治理、内部控制等制度设计,降低住处不对称的程度,从而降低道德风险,并保证组合风险管理和交易风险管理