nPLS-00306: wrong number or types of arguments in

2019-08-14 17:41发布

Excuse me if question is being repeated. I have two projects in my solution, a console application and a MVC4 website. I'm using Oracle managed drviers for accessing oracle database 11g. I'm trying to retrieve data from following stored procedure:

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

After making entities and other stuff in my console application, I get data by doing:

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

I have added reference of this console application in my website but when I call above method in my controller it gives exception:

"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"}

at following line in context class

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

Is there anything I'm missing?

2条回答
再贱就再见
2楼-- · 2019-08-14 18:00

Your procedure GETEMPIDS accepts p_cursor OUT SYS_REFCURSOR as a parameter. Apparently, you have to declare a ResultSet and pass it to the procedure. Like this:

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

Oops, ResultSet is for Java, I didn't notice C# in the tags. Anyway, I hope you get the idea.

查看更多
Animai°情兽
3楼-- · 2019-08-14 18:01

When we add a result of Stored Procedure in entities, it adds some code relating to output fields in config file.

 <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>

My problem was solved when I copied that code and pasted it in config file of my website.

查看更多
登录 后发表回答