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

十年热恋 提交于 2019-12-24 06:46:02

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/29602549/npls-00306-wrong-number-or-types-of-arguments-in-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!