4

I'm executing a stored procedure from Oracle DB that is:

PROCEDURE GET_TIM_USER_CUSTO(P_ANOMES IN VARCHAR, USER_CUSTO OUT SYS_REFCURSOR)
    IS

    BEGIN

    OPEN USER_CUSTO FOR
    SELECT ID, COD_UTILIZADOR,ANO_MES,
        TO_NUMBER(DESENCRIPTAR_DADO(CUSTO, (SELECT VALOR 
                                FROM TIM_CONFIG
                                WHERE PARAMETRO='CRIPT_KEY'))) CUSTO,
        TO_NUMBER(DESENCRIPTAR_DADO(CUSTO_EXTRA, (SELECT VALOR 
                                FROM TIM_CONFIG
                                WHERE PARAMETRO='CRIPT_KEY'))) CUSTO_EXTRA
   FROM TIM_USER_CUSTO
        WHERE SUBSTR(P_ANOMES, 1, 4)=SUBSTR(ANO_MES, 1, 4);


END GET_TIM_USER_CUSTO;

If I execute it on the Oracle directly it returns a result set well. But If I call this stored procedure in a WebService using Entity Framework

ORA-01722: invalid number

Calling:

ObjectResult<USER_CUSTO> aux = context.TIM_FUNCTIONS_GET_TIM_USER_CUSTO(sAnoMes);

Then it throws an exception, doesn't give any result.

Andre Roque
  • 503
  • 1
  • 9
  • 31
  • Please show the result you get and how you call it using EntityFramework – Adil Mammadov Aug 29 '16 at 12:01
  • What's the definition of your USER_CUSTO? Can you also provide the result you get when you run the query? According to the [docs](http://www.dba-oracle.com/sf_ora_01722_invalid_number.htm) this error is an "... attempted conversion of a character string to a number failed because the character string was not a valid numeric literal." – n0m4d Aug 29 '16 at 17:06

1 Answers1

1

Using stored procedure with entity can be an extremely complicated thing, i've been extremely frustrated when i first tried. Everything works well in entity... exept stored procedure... anyway. If one of these can help you, i realy suggest you read these questions/answers below and try to find your way out of this, good luck !

using stored procedure in entity framework

Getting data from stored procedure with Entity Framework

Sql Stored proc and Entity framework 6

Community
  • 1
  • 1
Antoine Pelletier
  • 3,164
  • 3
  • 40
  • 62