Call oracle Stored Procedure with EF fail

I have an oracle store procedure which take 2 strings and a date in input parametter and which give a ref cursor as output :

CREATE OR REPLACE PROCEDURE SCHEMA.MYPROSTO (
   pPl    IN     VARCHAR2, -- Comma (;) separated
   pTy    IN     VARCHAR2,-- Comma (;) separated
   pDate     IN     mytable.mydate%TYPE,
   pCursor      OUT sys_refcursor)
IS
   .....
   sSQL      VARCHAR2 (3000);
BEGIN

   -- making SQL Order
   sSQL := 'SELECT TO_CHAR (v.date_c........

   ......


   OPEN pCursor FOR sSQL;

END MYPROSTO;

The output cursor return a set of 3 string cells rows.

I imported this stored procedure in my entity framework model, with this in the .config file :

<oracle.manageddataaccess.client>
<version number="*">
  <implicitRefCursor>
    <storedProcedure schema="SCHEMA" name="MYPROSTO">
      <refCursor name="PCURSOR">
        <bindInfo mode="Output"/>
        <metadata columnOrdinal="0" columnName="YEAR" providerType="Varchar2" allowDBNull="true" nativeDataType="Varchar2"/>
        <metadata columnOrdinal="1" columnName="MONTH" providerType="Varchar2" allowDBNull="true" nativeDataType="Varchar2"/>
        <metadata columnOrdinal="2" columnName="COUNT" providerType="Varchar2" allowDBNull="true" nativeDataType="Varchar2"/>
      </refCursor>
    </storedProcedure>
  </implicitRefCursor>
</version>
</oracle.manageddataaccess.client>

The function import wizzard created a result object and generated an access function :

public virtual ObjectResult<MYPROSTO_Result> MYPROSTO (string pPL, string pTY, Nullable<System.DateTime> pDATE)
{
    var pPLParameter = pPL!= null ?
        new ObjectParameter("PPL", pPL) :
        new ObjectParameter("PPL", typeof(string));

    var pTYParameter = pTY!= null ?
        new ObjectParameter("PTY", pTY) :
        new ObjectParameter("PTY", typeof(string));

    var pDATEParameter = pDATE.HasValue ?
        new ObjectParameter("PDATE", pDATE) :
        new ObjectParameter("PDATE", typeof(System.DateTime));

    return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<MYPROSTO_Result>("MYPROSTO", pPLParameter, pTYParameter, pDATEParameter);
}

However, the call to this function raise an exception ( System.Data.Entity.Core.EntityCommandExecutionException ) on the last line :

ORA-06550: Ligne 1, colonne 8 : PLS-00306: wrong number or types of arguments in call to 'MYPROSTO'
ORA-06550: Ligne 1, colonne 8 : PL/SQL: Statement ignored

I don't see why it fail


There appears to be several problems:

  • Sending a varchar(2) into a date field
  • The name of a parameter "pTY" versus "pType"
  • The name of a parameter "pPL" versus "pPlant"
  • The name of a parameter "PPLT" versus "PPL"

  • What about return parameter. It is "mapped" ok? DoubleCheck


    Surely the answer is clear in the error message:

    "wrong number or types of arguments in call to 'MYPROSTO'"

    Your procedure expects 4 parameters but you're only passing 3. You need an output variable for the refcursor.

    链接地址: http://www.djcxy.com/p/27298.html

    上一篇: 如何重置模拟器中的钥匙串?

    下一篇: 使用EF调用Oracle存储过程失败