《C#调用Oracle的存储过程,其参数为数组类型》由会员分享,可在线阅读,更多相关《C#调用Oracle的存储过程,其参数为数组类型(5页珍藏版)》请在技术文库上搜索。

1、C#C#调用调用 OracleOracle 的存储过程的存储过程, ,其参数为数组类型其参数为数组类型 C#调用 Oracle 的存储过程,其参数为数组类型”中的 Package 收 藏 using Oracle.DataAccess; using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; . private void button4_Click(object sender, System.EventArgs e) string connectionstring=string.Concat ( “Password=123“。

2、, “;User ID=user“, “;Data Source=oradata“ ); OracleConnection con=new OracleConnection(connectionstring); try con.Open(); OracleCommand cmd=con.CreateCommand(); / / / cmd.CommandType=CommandType.StoredProcedure; cmd.CommandText=“packtest.test“; / /定义 Parameter,其中, Size 是数组中的元素数量 / OracleParameter Pa。

3、ram1 = new OracleParameter(“p1“,OracleDbType.Varchar2,3); OracleParameter Param2 = new OracleParameter(“p2“,OracleDbType.Int32,3); / Param1.Direction = ParameterDirection.Input; Param2.Direction = ParameterDirection.Output; / Specify that we are binding PL/SQL Associative Array Param1.CollectionType。

4、 = OracleCollectionType.PLSQLAssociativeArray; Param2.CollectionType = OracleCollectionType.PLSQLAssociativeArray; / Setup the values for PL/SQL Associative Array Param1.Value = new string3“First Element“, “Second Element “, “Third Element “; Param2.Value = null; / Specify the maximum number of elem。

5、ents in the PL/SQL Associative /Array / / Setup the ArrayBindSize for Param1 Param1.ArrayBindSize = new int313, 14, 13; / Setup the ArrayBindStatus for Param1 Param1.ArrayBindStatus = new OracleParameterStatus3 OracleParameterStatus.Success, OracleParameterStatus.Success, OracleParameterStatus.Succe。

6、ss; / Setup the ArrayBindSize for Param2 /对于 Int 类型的 Parameter,可以不设置 Size,因为本身 Int 定义了自身大小 / / Param2.ArrayBindSize = new int31, 2, 1; cmd.Parameters.Add(Param1); cmd.Parameters.Add(Param2); / execute the cmd cmd.ExecuteNonQuery(); /print out the parameters values int matrixint=(int)Param2.Value; foreach(int t in matrixint) ShowMessage(t.ToString(); / con.Close(); catch(Exception ex) MessageBox.Show(string.Concat( ex.Message, “rn“, ex.Source.ToString(), “rn“, ex.TargetSite.ToString(), “rn“, ex.StackTrace.ToString() ); finally con.Close(); 。

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐