怎么过一个参数给oracle函数? [英] How past more that a parameter to oracle function?

查看:79
本文介绍了怎么过一个参数给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函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆