.Net Core 调用Oracle 存储过程
安装nuget包
Oracle.ManagedDataAccess.Core
注意
ParameterDirection.InputOutput 输入输出参数
参数最好指定长度
try { var constr = GetConfig("OracleConn"); using var con = new OracleConnection(constr); con.Open(); // Call stored procedure var odbcCommand = con.CreateCommand(); odbcCommand.CommandText = "SP_"; odbcCommand.CommandType = CommandType.StoredProcedure; var codePara = new OracleParameter("Code", OracleDbType.Varchar2, ParameterDirection.InputOutput) { Value = Code }; var TypePara = new OracleParameter("Type", OracleDbType.NVarchar2, 20, null, ParameterDirection.Output); odbcCommand.Parameters.Add(codePara); odbcCommand.Parameters.Add(TypePara); odbcCommand.ExecuteNonQuery(); Code = codePara.Value; Type = TypePara.Value; // Close and Dispose OracleConnection con.Close(); } catch (OracleException oex) { Code = ""; Type = ""; }