Skip to content

oracle stored procedure returning cursor  #68

@martinRocks

Description

@martinRocks

I just found your package and I think it will make my code read a ton better. Right now, my code looks like the first code block. It works fine, but I would like to make my code look the second code block, but it can't seem to figure out how to set the returning cursor. I think I'm close in the second code block. As you can see, I'm stuck in an oracle database where every stored procedure returns a refcursor.

List<Dto> data;
var connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
using (var connection = new OracleConnection(connStr))
{
     var values = new OracleDynamicParameters();
     values.Add("i_uic", Uic, OracleMappingType.Varchar2, ParameterDirection.Input);
     values.Add("o_cur", dbType: OracleMappingType.RefCursor, direction: ParameterDirection.Output);

     data = connection.Query<Dto>("jcn_exports.get_work_notifications", values, commandType: CommandType.StoredProcedure).ToList();
}
List<Dto> data;
var connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
using (var connection = new OracleConnection(connStr))
{
     var ocur = new OracleParameter("o_cur", OracleDbType.RefCursor, ParameterDirection.Output);
     var query = connection.SqlBuilder(
                    new InterpolatedSqlBuilderOptions(){DatabaseParameterSymbol = ":"},
                    $"jcn_exports.get_work_notifications({Uic}, {ocur})");
     data = query.Query<Dto>().ToList();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions