怎么过一个参数给oracle函数?

编程入门 行业动态 更新时间:2024-10-22 20:25:59
本文介绍了怎么过一个参数给oracle函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个Oracle函数,它接收状态并返回另一个状态,该函数无法修改,我想知道是否有人更好地了解如何迭代相同的函数传递状态列表。 谢谢。

I have an Oracle function that receives a status and returns another status, that function can not be modified and I wanted to know if someone has a better idea of how iterating the same function passing it a status list. Thanks.

public List<string> GetStatusNotDisplayTCByList(List<string> status) { try { List<string> result = new List<string>(); using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["dbnet"].ConnectionString)) { using (OracleCommand comm = new OracleCommand("pkg_aut_module.fn_get_status", conn)) { comm.CommandType = CommandType.StoredProcedure; comm.BindByName = true; comm.ArrayBindCount = status.Count; comm.Parameters.Add("p_status", OracleDbType.Varchar2, status.ToArray(),ParameterDirection.Input); comm.Parameters.Add("Vli", OracleDbType.RefCursor, null, ParameterDirection.ReturnValue); DataTable dt = new DataTable(); conn.Open(); using (OracleDataReader reader = comm.ExecuteReader()) { if (reader.HasRows) { dt.Load(reader); List<DataRow> dr = dt.AsEnumerable().ToList(); while (reader.Read()) { foreach (var row in dr.AsEnumerable()) { result.Add(Convert.ToString(row["status_display"])); } } reader.Close(); conn.Dispose(); } } } } return result; } catch (Exception e) { throw; } }

我尝试了什么: 我试图将多个参数传递给Oracle函数,如果不可能,我想知道如何以有效的方式多次调用该函数。

What I have tried: I am trying to pass more than one parameter to an Oracle function and if it was not possible I wanted to know how I could call the function several times in an effective way.

推荐答案

如果你的proc有输出参数,有很多方法可以做到。如果没有,那么你只需循环 There are ways to do it if your proc has an output parameter. If not then you'll just have to loop

更多推荐

怎么过一个参数给oracle函数?

本文发布于:2023-10-31 06:04:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545230.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   参数   oracle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!