数据库:
create or replace procedure proce_test(paramin in varchar2,paramout out varchar2,paraminout in out varchar2)as
varparam varchar2(28);
begin
varparam:=paramin;
paramout:=varparam|| paraminout;
end;
c#代码:
OracleConnection conn = null;
OracleCommand cmd = null;
string strConn = "data source=clientag;user id=ay_plan;password=ayplan"; //连接数据库
conn = new OracleConnection(strConn);
try
{
conn.Open();
cmd = new OracleCommand();
cmd.Connection = conn;
}
catch (Exception e)
{
throw e;
}
OracleParameter[] parameters ={
new OracleParameter("paramin",OracleType.VarChar,20),
new OracleParameter("paramout",OracleType.VarChar,20),
new OracleParameter("paraminout",OracleType.VarChar,20)
};
parameters[0].Value = "bjd";
parameters[2].Value = "cs";
parameters[0].Direction = ParameterDirection.Input;
parameters[1].Direction = ParameterDirection.Output;
parameters[2].Direction = ParameterDirection.InputOutput;
try
{
cmd.CommandText = "proce_test";//声明存储过程名
cmd.CommandType = CommandType.StoredProcedure;
foreach (OracleParameter parameter in parameters)
{
cmd.Parameters.Add(parameter);
}
cmd.ExecuteNonQuery();//执行存储过程
Console.WriteLine(parameters[1].Value.ToString());
Console.Read();
}
catch (Exception e)
{
throw e;
}
显示结果: