Oracle獲取SP的參數

 

--根據SP的名字取SP的參數列表
 SELECT argument_name, position - 1
    FROM all_arguments
   WHERE owner = 'MES1' AND object_name = 'QUERY'
ORDER BY sequence

 

        /// <summary>
        /// 根據SP的名字取SP的參數列表;
        /// </summary>
        /// <param name="strSPName"></param>
        /// <returns></returns>
        public static DataTable GetSPPataList(string strSPName)
        {
            DataTable dtTemp = new DataTable();
            string strConString = System.Web.HttpContext.Current.Session["conString"].ToString();
            string strSQL = "SELECT argument_name, position-1                      " +
                            "FROM all_arguments                                    " +
                            "WHERE owner = 'MES1' AND object_name = :object_name   " +
                            "ORDER BY sequence                                     ";
            OracleParameter[] oraParas = new OracleParameter[]{
                    new OracleParameter(":object_name",strSPName.ToUpper())
            };
            dtTemp = DBHelper.OracleHelper.ExecuteDataTable(strConString, CommandType.Text, strSQL, oraParas);

            return dtTemp;
        }

 

 

 public static System.Data.DataTable ExecuteDataTable(string connectionString, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters)
        {
            //Create the command and connection
            OracleCommand cmd = new OracleCommand();
            OracleDataAdapter adp=new OracleDataAdapter();
            OracleConnection conn = new OracleConnection(connectionString);

            try
            {
                //Prepare the command to execute
                PrepareCommand(adp,cmd, conn, null, cmdType, cmdText, commandParameters);

                //Execute the query, stating that the connection should close when the resulting datareader has been read
                DataTable dtTemp = new DataTable();
                adp.Fill(dtTemp);
                cmd.Parameters.Clear();
                conn.Dispose();
                return dtTemp;
            }
            catch
            {
                //If an error occurs close the connection as the reader will not be used and we expect it to close the connection
                conn.Close();
                throw;
            }
        }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值