nPLS-00306:调用中的参数数量或类型错误

nPLS-00306: wrong number or types of arguments in call

如果重复问题,请原谅。我的解决方案中有两个项目,一个控制台应用程序和一个 MVC4 网站。我正在使用 Oracle 托管驱动程序访问 oracle 数据库 11g。我正在尝试从以下存储过程中检索数据:

create or replace procedure "GETEMPIDS"
    (
       p_cursor OUT SYS_REFCURSOR
    )
is
begin
    OPEN p_cursor FOR
select *
    from EMP;
end;​

在我的控制台应用程序中制作实体和其他内容后,我通过以下方式获取数据:

 public List<GETEMPIDS_Result> GetAllEmployees()
        {
            Entities db = new Entities();
            List<GETEMPIDS_Result> result = db.GETEMPIDS().ToList<GETEMPIDS_Result>();
            return result;
        }

我在我的网站上添加了这个控制台应用程序的引用,但是当我在我的控制器中调用上面的方法时,它给出了异常:

"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETEMPIDS'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"}

在上下文中的下一行 class

public virtual System.Data.Entity.Core.Objects.ObjectResult<GETEMPIDS_Result> GETEMPIDS()
        {
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GETEMPIDS_Result>("GETEMPIDS");
        }

有什么我遗漏的吗?

您的程序 GETEMPIDS 接受 p_cursor OUT SYS_REFCURSOR 作为参数。显然,您必须声明一个 ResultSet 并将其传递给该过程。像这样:

ResultSet rs = new ResultSet;
List<GETEMPIDS_Result> result = db.GETEMPIDS(  rs  ).ToList<GETEMPIDS_Result>();

糟糕,ResultSet 用于 Java,我没有注意到标签中的 C#。 不管怎样,我希望你能明白。

当我们在实体中添加存储过程的结果时,它会在配置文件中添加一些与输出字段相关的代码。

 <implicitRefCursor>
    <storedProcedure schema="AHSEN" name="GETEMPIDS">
      <refCursor name="P_CURSOR">
        <bindInfo mode="Output" />
        <metadata columnOrdinal="0" columnName="EMPNO" providerType="Int16" allowDBNull="false" nativeDataType="Number" />
        <metadata columnOrdinal="1" columnName="ENAME" providerType="Varchar2" allowDBNull="true" nativeDataType="Varchar2" />
        <metadata columnOrdinal="2" columnName="JOB" providerType="Varchar2" allowDBNull="true" nativeDataType="Varchar2" />
        <metadata columnOrdinal="3" columnName="MGR" providerType="Int16" allowDBNull="true" nativeDataType="Number" />
        <metadata columnOrdinal="4" columnName="HIREDATE" providerType="Date" allowDBNull="true" nativeDataType="Date" />
        <metadata columnOrdinal="5" columnName="SAL" providerType="Single" allowDBNull="true" nativeDataType="Number" />
        <metadata columnOrdinal="6" columnName="COMM" providerType="Single" allowDBNull="true" nativeDataType="Number" />
        <metadata columnOrdinal="7" columnName="DEPTNO" providerType="Int16" allowDBNull="true" nativeDataType="Number" />
      </refCursor>
    </storedProcedure>
  </implicitRefCursor>

当我复制该代码并将其粘贴到我网站的配置文件中时,我的问题就解决了。