日期:2014-05-20 浏览次数:20795 次
//Create a hashtable for the parameter cached private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable());
public static OracleParameter[] GetCachedParameters(string cacheKey) { OracleParameter[] cachedParms = (OracleParameter[])parmCache[cacheKey]; if (cachedParms == null) return null; // If the parameters are in the cache OracleParameter[] clonedParms = new OracleParameter[cachedParms.Length]; // return a copy of the parameters for (int i = 0, j = cachedParms.Length; i < j; i++) clonedParms[i] = (OracleParameter)((ICloneable)cachedParms[i]).Clone(); return clonedParms; }
private static OracleParameter[] GetOrderParameters() { OracleParameter[] parms = OracleHelper.GetCachedParameters(SQL_INSERT_ORDER); if (parms == null) { parms = new OracleParameter[] { new OracleParameter(PARM_ORDER_ID, OracleType.Number, 10), new OracleParameter(PARM_USER_ID, OracleType.VarChar, 80), new OracleParameter(PARM_DATE, OracleType.DateTime), new OracleParameter(PARM_SHIP_ADDRESS1, OracleType.VarChar, 80), new OracleParameter(PARM_SHIP_ADDRESS2, OracleType.VarChar, 80), new OracleParameter(PARM_SHIP_CITY, OracleType.VarChar, 80), new OracleParameter(PARM_SHIP_STATE, OracleType.VarChar, 80), new OracleParameter(PARM_SHIP_ZIP, OracleType.VarChar, 50), new OracleParameter(PARM_SHIP_COUNTRY, OracleType.VarChar, 50), new OracleParameter(PARM_BILL_ADDRESS1, OracleType.VarChar, 80), new OracleParameter(PARM_BILL_ADDRESS2, OracleType.VarChar, 80), new OracleParameter(PARM_BILL_CITY, OracleType.VarChar, 80), new OracleParameter(PARM_BILL_STATE, OracleType.VarChar, 80), new OracleParameter(PARM_BILL_ZIP, OracleType.VarChar, 50), new OracleParameter(PARM_BILL_COUNTRY, OracleType.VarChar, 50), new OracleParameter(PARM_TOTAL, OracleType.Number), new OracleParameter(PARM_BILL_FIRST_NAME, OracleType.VarChar, 80), new OracleParameter(PARM_BILL_LAST_NAME, OracleType.VarChar, 80), new OracleParameter(PARM_SHIP_FIRST_NAME, OracleType.VarChar, 80), new OracleParameter(PARM_SHIP_LAST_NAME, OracleType.VarChar, 80), new OracleParameter(PARM_AUTHORIZATION_NUMBER, OracleType.Int32)}; OracleHelper.CacheParameters(SQL_INSERT_ORDER, parms); } return parms; } }