/// <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, ));
parameters.Add(new SqlParameter("@key_value", SqlDbType.Decimal, ));
parameters[].Value = tablename;
parameters[].Direction = ParameterDirection.Output;
break;
case "Oracle":
parameters = new List<DbParameter>();
parameters.Add(new OracleParameter(":tb_name", Oracle.ManagedDataAccess.Client.OracleDbType.Varchar2, ));
parameters.Add(new OracleParameter(":key_value", Oracle.ManagedDataAccess.Client.OracleDbType.Decimal));
parameters[].Value = tablename;
parameters[].Direction = ParameterDirection.Input;
parameters[].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"为存储过程名称
public DataSet QueryDiagnosisAccordanceRate(string startDate, string endDate, string modality, string hospitalid)
{
switch (sqlType)
{
case "MSSQL2008":
parameters = new List<DbParameter>();
parameters.Add(new SqlParameter("@startDate", startDate));
parameters.Add(new SqlParameter("@endDate", endDate));
parameters.Add(new SqlParameter("@modality", modality));
parameters.Add(new SqlParameter("@hospitalid", hospitalid));
break;
case "Oracle":
parameters = new List<DbParameter>();
parameters.Add(new OracleParameter(":startDate", startDate));
parameters.Add(new OracleParameter(":endDate", endDate));
parameters.Add(new OracleParameter(":modality", modality));
parameters.Add(new OracleParameter(":hospitalid", hospitalid));
OracleParameter p = new OracleParameter(":p_record", OracleDbType.RefCursor);
p.Direction = ParameterDirection.Output;
parameters.Add(p);
break;
default: break;
}
IDBHelper dbhelper = DBFactory.createDBHleper();
return dbhelper.RunProcedure(Utility.DB.PubConstant.ConnectionString, "Proc_DiagnosisAccordance", parameters, "ds");
}