/// <summary>
/// 构造ORACLE查询中IN条件超过1000个键值后拆分的条件 2009年6月5日 kitleer
/// </summary>
/// <param name="keys">主键ID集合:形式为'key1','key2','key3'...</param>
/// <param name="field">作为条件的字段名称</param>
/// <returns></returns>
///
public static string Ora01795(string keys, string field)
{
string tempSql = string.Empty;
int idslen = keys.Split(',').Length;
int reply = Convert.ToInt32(System.Math.Ceiling((double)idslen / (double)1000));
for (int i = 0; i < reply; i++)
{
string tempids = string.Empty;
for (int j = 0; j < 1000; j++)
{
if (idslen > j + i * 1000)
{
if (!string.IsNullOrEmpty(keys.Split(',')[j + i * 1000]))
tempids += string.Format("{0},", keys.Split(',')[j + i * 1000]);
}
}
if (tempids.EndsWith(","))
tempids = tempids.Substring(0, tempids.Length - 1);
tempSql += string.Format("{1} in ({0}) or ", tempids, field);
}
tempSql += "1<>1";
return tempSql;
}
/// 构造ORACLE查询中IN条件超过1000个键值后拆分的条件 2009年6月5日 kitleer
/// </summary>
/// <param name="keys">主键ID集合:形式为'key1','key2','key3'...</param>
/// <param name="field">作为条件的字段名称</param>
/// <returns></returns>
///
public static string Ora01795(string keys, string field)
{
string tempSql = string.Empty;
int idslen = keys.Split(',').Length;
int reply = Convert.ToInt32(System.Math.Ceiling((double)idslen / (double)1000));
for (int i = 0; i < reply; i++)
{
string tempids = string.Empty;
for (int j = 0; j < 1000; j++)
{
if (idslen > j + i * 1000)
{
if (!string.IsNullOrEmpty(keys.Split(',')[j + i * 1000]))
tempids += string.Format("{0},", keys.Split(',')[j + i * 1000]);
}
}
if (tempids.EndsWith(","))
tempids = tempids.Substring(0, tempids.Length - 1);
tempSql += string.Format("{1} in ({0}) or ", tempids, field);
}
tempSql += "1<>1";
return tempSql;
}