简体   繁体   English

使用devart dotConnect调用Oracle存储过程

[英]Call Oracle stored procedures using devart dotConnect

I'm new in Entity Framework and trying to call oracle stored procedures, but without success. 我是Entity Framework的新成员,并尝试调用oracle存储过程,但未成功。 So Here is my question: 所以这是我的问题:

How to call oracle stored procedures using devart dotConnect? 如何使用devart dotConnect调用oracle存储过程?

For example, I have stored procedure: 例如,我有存储过程:

procedure get_problems(res out sys_refcursor) is
  begin

   open res 
   for
   select id, name
   from problems;  

  end;

And from C# I'm tying to call: 从C#我想打电话给:

 using (Entities entities = new Entities())
 {
     ObjectParameter res = new ObjectParameter("res", typeof(byte[]));
     ObjectResult<PROBLEM> problems = entities.SelectAllProblems(res);
 }

But it throws "EntityCommandExecutionException": 但是会抛出“ EntityCommandExecutionException”:

An error occurred while executing the command definition. 执行命令定义时发生错误。 See the inner exception for details. 有关详细信息,请参见内部异常。

Here is the inner exception: 这是内部的例外:

ORA-06550: line 2, column 3:\\nPLS-00306: wrong number or types of arguments in call to 'GET_PROBLEMS'\\nORA-06550: line 2, column 3:\\nPL/SQL: Statement ignored ORA-06550:第2行,第3列:\\ nPLS-00306:调用“ GET_PROBLEMS”时参数的数量或类型错误\\ nORA-06550:第2行,第3列:\\ nPL / SQL:语句被忽略

I used 我用了

"typeof(byte[])" “ typeof(byte [])”

as ObjectParameter type, because I saw this in Devart Entity Developer's generated code. 作为ObjectParameter类型,因为我在Devart Entity Developer的生成代码中看到了这一点。

ps By the way, how will you recommend dotConnect in large projects? ps顺便说一下,您如何在大型项目中推荐dotConnect?

I know this was asked a while ago but it might help someone else as it took me a while to figure this out. 我知道这个问题是在不久前被问到的,但它可能会帮助其他人,因为我花了一些时间才弄清楚这一点。 Here's how we call a stored proc (SID_PGet) within a package (P_SID) and return a single string value using DotConnect. 这是我们在包(P_SID)中调用存储的proc(SID_PGet)并使用DotConnect返回单个字符串值的方式。 (This only returns a single value - I'm currently trying to find out how to return a sys_refcursor). (这仅返回一个值-我目前正在尝试找出如何返回sys_refcursor)。

Here's the stored proc: 这是存储的过程:

PROCEDURE SID_PGet(io_SID OUT varchar2) is
Begin
   io_SID:=GetSID; -- GetSID returns a unique varchar value
End;

And in the DbContext in C#: 在C#的DbContext中:

public string GetNextSId()
{
    var parameter = new Devart.Data.Oracle.OracleParameter("io_SID", Devart.Data.Oracle.OracleDbType.VarChar, ParameterDirection.Output);
    this.Database.ExecuteSqlCommand("BEGIN P_SID.SID_PGet(:io_SID); END;", parameter);
    var sid = parameter.Value as string;

    return sid;
}

Take a look at this article in our blog. 看看我们博客中的这篇文章
You can contact us using our Forums or Feedback Page . 您可以使用我们的论坛反馈页面与我们联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Devart DotConnect 在针对 Oracle 使用实体框架 6 时得到了意外的长小数点 - Devart DotConnect got unexpected long decimal point for me while using entity framework 6 against Oracle 使用 Entity Framework Code First 连接到带有 devart dotconnect 的旧版 Oracle 数据库 - Using Entity Framework Code First to connect to Legacy Oracle Database with devart dotconnect DevArt dotConnect for Oracle在EF 4.0字符串上具有奇怪的行为 - DevArt dotConnect for Oracle with strange behavior on strings with EF 4.0 使用Benchmark.NET + DevArt dotConnect for PostgreSQL的许可错误 - License error using Benchmark.NET + DevArt dotConnect for PostgreSQL 从C#调用Oracle中的存储过程 - Call stored procedures in Oracle from C# Oracle数据库在C#中使用devart从存储过程返回错误的行 - Oracle database returns faulty rows from stored procedure using devart in C# 如何首先为SQLite代码配置Devart dotConnect? - How Configure Devart dotConnect for SQLite Code First? Devart dotconnect-有没有办法强制提交顺序? - Devart dotconnect - Is there a way to force the commit order? 无法查询 sqlite 的 devart dotconnect 中的数据 - cannot query for data in devart dotconnect for sqlite 使用Devart的EntityFramework与Oracle的连接不起作用 - EntityFramework connection to Oracle using Devart not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM