0

I'm trying to call a oracle function with my c# code using nhibernate, but it throws me this error: ORA-06550: line 1, column 15:\nPLS-00382: expression is of wrong type\nORA-06550: line 1, column 7:\nPL/SQL: Statement ignored"}

Here is the function:

CREATE OR REPLACE FUNCTION OID_VAL_MOVIMIENTOS
(
  v_usuario   IN       NUMBER,
  v_archivo   IN       VARCHAR2
)
RETURN NUMBER
AS
  v_cont NUMBER;
BEGIN

  v_cont := 150;
  RETURN v_cont;
END;

here is my hbm.xml file

<sql-query name="ValidaMovimientos">
  {? = call OID_VAL_MOVIMIENTOS(:v_usuario,:v_archivo)}
</sql-query>

And finally this is my c# code:

using (ISession session = NHibernateHelper.OpenSession())
{
    IQuery query = session.GetNamedQuery("ValidaMovimientos");
    query.SetDecimal("v_usuario", idUsuario);
    query.SetString("v_archivo", nombreArchivo);
    object str = query.UniqueResult();
}

I don't know what happend with that...

1 Answer 1

1

well you should better define the named query

<sql-query name="ValidaMovimientos">
    <query-param name="v_usuario" type="decimal"/>
    <query-param name="v_archivo" type="string"/>
    <return-scalar column="ResultVal" type="decimal"/>
    select call OID_VAL_MOVIMIENTOS(:v_usuario,:v_archivo) as ResultVal
</sql-query>

the select call OID_VAL_MOVIMIENTOS(:v_usuario,:v_archivo) as ResultVal may be syntactically wrong for oracle, modify as needed as my oracle-syntax is rusty

Sign up to request clarification or add additional context in comments.

1 Comment

I try with a cursor in the function and now its working, but when i try to return an excalar value, it throw me the error above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.