Unable to hit oracle stored proc using .Net EF(2.2) Core repository pattern

.net entity-framework-core oracle oracle-sqldeveloper repository-pattern

Question

ORA-00900: invalid SQL statement

This is the error i get when i am trying to hit a stored procedure(in Oracle) from my API.

I am using Repository pattern with Entity framework.(EF Core 2.2)

This is my call,

return FetchWithStoredProcedure("PROC_GETMYPROC",
     new OracleParameter("PARAM1", OracleDbType.Int32, ParameterDirection.Input) { Value = PageNo },
     new OracleParameter("PARAM2", OracleDbType.Int32,ParameterDirection.Input) { Value = PageSize },
     new OracleParameter("PARAM3", OracleDbType.Varchar2, 30, ParameterDirection.Input) { Value = SearchTerm },
     new OracleParameter("PARAM4", OracleDbType.Int32, ParameterDirection.InputOutput) { Value = TotalRows },
     new OracleParameter("PARAM5",OracleDbType.RefCursor, ParameterDirection.Output)
                     ).ToList();

This is my FetchWithStoreProcedure method

public IEnumerable<T> FetchWithStoredProcedure(string query, params object[] parameters)
{
    return _entities.Set<T>().FromSql(query, parameters);
}

And this is the exception thrown.

enter image description here

1
0
3/31/2020 2:53:10 PM

Popular Answer

Kindly try like the below

      return FetchWithStoredProcedure("BEGIN PROC_GETMYPROC(@PARAM1,@PARAM2,@PARAM3
       ,@PARAM4,@PARAM5); END",
0
4/1/2020 5:41:14 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow