开发者

NHibernate to access Oracle stored procedure REFCURSOR and output parameter

Does the cur开发者_C百科rent version of NHibernate (v2.1.2) support access Oracle stored procedure output REFCURSOR in addition to an output parameter?

I can access the output refcursor fine with my code. However i'm not sure i can access the additional output param in the same stored procedure.

Some sample of calling syntax would be greatly appreciated. thanks.


Nope it does not. Only one refcursor is supported and it has to be the first parameter in the sproc.

You can always get the IDbConnection from the session and then use plain ODP.Net for such scenarios (you lose nh functionality) or rather change the stored procedure.


I found a solution to call old stored procedures with NHibernate.

I don't think that is the better way, but we normally don't have time to refactor everything, so:

using (ITransaction transaction = _session.BeginTransaction()) {
    IDbCommand command = new OracleCommand();
    command.Connection = _session.Connection;

    command.CommandType = CommandType.StoredProcedure;
    command.CommandText = "pk_package.pr_procedure";

    // Set input parameters
    var param1 = new OracleParameter("@param1", OracleDbType.Decimal) {Value = someField};
    var param2 = new OracleParameter("@param2", OracleDbType.Decimal) {Value = 1};

    command.Parameters.Add(param1);
    command.Parameters.Add(param2);

    // Execute the stored procedure
    command.ExecuteNonQuery();
    transaction.Commit();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜