C# 获取 oracle 存储过程的 返回值1
时间:2021-07-01 10:21:17
帮助过:2人阅读
<summary>
/// 返回对应表的模拟自增字段值
/// </summary>
/// <param name="tablename">表名</param>
/// <returns>表的模拟自增字段值</returns>
public decimal GetPKNum(
string tablename)
{
switch (sqlType)
{
case "MSSQL2008":
parameters =
new List<DbParameter>
();
parameters.Add(new SqlParameter(
"@table_name", SqlDbType.VarChar,
50));
parameters.Add(new SqlParameter(
"@key_value", SqlDbType.Decimal,
9));
parameters[0].Value =
tablename;
parameters[1].Direction =
ParameterDirection.Output;
break;
case "Oracle":
parameters =
new List<DbParameter>
();
parameters.Add(new OracleParameter(
":tb_name", Oracle.ManagedDataAccess.Client.OracleDbType.Varchar2,
50));
parameters.Add(new OracleParameter(
":key_value", Oracle.ManagedDataAccess.Client.OracleDbType.Decimal));
parameters[0].Value =
tablename;
parameters[0].Direction =
ParameterDirection.Input;
parameters[1].Direction =
ParameterDirection.Output;
break;
default:
break;
}
IDBHelper dbhelper =
DBFactory.createDBHleper();
return dbhelper.RunProcedure(Utility.DB.PubConstant.ConnectionString,parameters,
"up_get_table_key");
}
IDBHelper dbhelper = DBFactory.createDBHleper();是后台创建了一个dbhelp文件,如果当时是Oracle数据库 dbhelper 就为 OracleHelper文件
此oracle 存储过程具有两个参数,key_value 是返回参数out
Utility.DB.PubConstant.ConnectionString是数据库连接字符串
"up_get_table_key"为存储过程名称
C# 获取 oracle 存储过程的 返回值1
标签: