开发者

Error calling oracle function with NHibernate

开发者 https://www.devze.com 2023-02-19 01:39 出处:网络
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

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 m开发者_如何转开发y 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...


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

0

精彩评论

暂无评论...
验证码 换一张
取 消