没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:李爽夏|2019-01-24 10:02:04.000|阅读 256 次
概述:本篇文章介绍如何在OracleCommand类的帮助下,使用Dotconnect for Oracle创建和使用Oracle存储过程和函数。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
【下载dotConnect for Oracle最新版本】
dotConnect for Oracle(原名OraDirect.NET)建立在ADO.NET技术上,为基于Oracle数据库的应用程序提供完整的解决方案。它为设计应用程序结构带来了新的方法,提高工作效率,使数据库应用程序的开发更简便。
本篇文章介绍如何在OracleCommand类的帮助下,使用Dotconnect for Oracle创建和使用Oracle存储过程和函数。
有两种通过OracleCommand执行存储过程的一般方法。
第一种方法是将过程调用包含到PL/SQL块中,并通过将其放入OracleCommand.CommandText属性来执行该块。在这种情况下,该过程返回的数据可以在同一块中立即处理。如果过程需要一些参数,则应将它们添加到OracleCommand.Parameters集合中。此方法与通常的命令执行没有区别。
第二种方法是将OracleCommand.CommandType设置为System.Data.commandType.StoredProcedure。在这种情况下,CommandText应该设置为过程的名称。以下示例显示如何使用上一节中的get-all-depts-proc过程填充数据表:
// Open the connection OracleConnection connection = new OracleConnection("Server=Ora; User Id=Scott; Password = tiger;"); connection.Open(); // Create a command OracleCommand command = new OracleCommand(); command.Connection = connection; // Set the CommandType property to execute // stored procedures or functions by this command command.CommandType = System.Data.CommandType.StoredProcedure; // Set the name of procedure or function to be executed command.CommandText = "get_all_depts_proc"; // The ParameterCheck property should be true to automatically // check the parameters needed for the procedure execution. command.ParameterCheck = true; // At this moment, the command is ready for execution. // As we have an output cursor parameter, we may use the command to fill a data table. OracleDataTable dt = new OracleDataTable(command, connection); dt.Fill();
Dim connection _ As New OracleConnection("Server=Ora; User Id=Scott; Password = tiger;") connection.Open() ' Create a command. Dim command = New OracleCommand() command.Connection = connection ' Set the CommandType property to execute stored procedures or functions by this command. command.CommandType = System.Data.CommandType.StoredProcedure ' Set the name of procedure or function to be executed. command.CommandText = "get_all_depts_proc" ' The ParameterCheck property should be true to automatically ' check the parameters needed for the procedure execution. command.ParameterCheck = True ' At this moment, the command is ready for execution. ' As we have an output cursor parameter, we may use the command to fill a data table. Dim dt = New OracleDataTable(command, connection) dt.Fill()
将CommandText设置为“get-all-depts-func”,相同的代码使用存储函数而不是过程填充数据表。
当执行ExecuteReader或ExecuteEscalar时,并且OracleCommand.CommandType设置为System.Data.commandType.StoredProcedure时,默认情况下将执行附加查询,以检查过程是否是流水线的,如果不是,则说明参数(签出光标参数)。这允许您在仅设置必要的过程参数后执行存储过程,而不必费心完全正确地填充参数集合,因为在获取元数据后,它将自动填充。
但是,执行附加查询可能不合适,并且在某些情况下可能会导致性能损失。Dotconnect for Oracle允许使用DescribeStoredProcedure连接字符串参数禁用此检查。
如果只将此连接字符串参数设置为false,OracleCommand将执行存储的例程,而不进行任何额外的检查。在这种情况下,例程不能是表值函数,它的所有参数都必须手动设置。
如果要在不进行其他检查的情况下执行表值函数,则需要将OracleCommand的IsTableValuedFunction属性设置为true。这允许您在不进行额外检查的情况下执行表值函数。将此属性设置为true也是执行非管道表值函数的唯一方法。即使describeStoredProcedure设置为true,也必须将IsTableValuedFunction设置为true才能执行非管道表值函数。
如果只对OracleCommand的单个实例禁用附加检查,而不禁用连接的附加检查,请将IsTableValuedFunction属性(根据执行的函数是否为表值,设置为true或false)和ImplicitRefCursors属性设置为false。设置IsTableValuedFunction属性将禁用检查执行的函数是否为表值,并将ImplicitRefCursors属性设置为false将禁用检查其他光标参数。
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@wqylolg.cn
单元格边框是指在单元格或单元格区域周围添加的线条。它们可用于不同的目的,如分隔工作表中的部分、吸引读者注意重要的单元格或使工作表看起来更美观。本文将介绍如何使用 Spire.XLS for .NET 在 C# 中添加或删除 Excel 单元格边框。
Excel 中的切片器是一种简单易用的工具,可以帮助用户过滤数据,让数据分析变得更加直观,交互性更强。这篇文章将介绍如何使用 Spire.XLS for .NET 在 C# 中添加、修改和删除 Excel 切片器。
本教程将向您展示如何用MyEclipse开发EJB 3无状态会话Bean,欢迎下载最新版IDE体验!
在处理 HTML 表中呈现的结构化数据时,将 HTML 转换为 Excel 是一种常见需求。使用 Aspose.Cells,我们可以轻松地将 HTML 文件转换为不同编程语言的 Excel。
dotConnect for Oracle不仅可以高效地连接到Oracle数据库,还提供了新的开发工具和技术。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@wqylolg.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢