This is due to the Oracle syntax constraints, in the number must be less than 1000, so take a full 1000 partition with or connected, the following is the solution:
/** * example:list sqhlist=[' aa ' "BB" "CC" "dd" "ee" "FF" "GG" ']; * Test.getsqlstrbylist (sqhlist,3, "shenqingh") = "shenqing" (' AA ', ' BB ', ' cc ') or Shenqingh in (' dd ', ' ee ', ' ff ') or ShenQi NGH in (' g * * * splits more than 1000 of the in condition set into a set of multiple splitnum of SQL. * * @param sqhlist * in condition list * @param splitnum * Split interval number, for example: $ * @param columnName * Field names referenced in SQL for example: Z.shenqingh * @return **/private static String getsqlstrbylist (List sqhlist, int splitnum,string Co Lumnname) {if (Splitnum > 1000)//Because the database has a list of SQL restrictions that cannot exceed 1000.return null; StringBuffer ids = new StringBuffer (""); if (sqhlist! = null) {Ids.append (""). Append (ColumnName). Append ("in ("); for (int i = 0; I < sqhlist.size (); i++) {ids.append ("'"). Append (Sqhlist.get (i) + "'"), if ((i + 1)% Splitnum = = 0 && (i + 1) < Sqhlist.size ()) {ID S.deletecharat (Ids.length ()-1), Ids.append (") OR"). Append (ColumnName). Append ("in (");}} Ids.deletecharat (Ids.length ()-1); Ids.append (")");} Return Ids.tostriNg ();} public static void Main (string[] args) {List List = new ArrayList (); int id = 2;for (int i=0;i<1020;i++) {list.add ("'" +id+ "'");} String ss = getsqlstrbylist (list, N, "test"); SYSTEM.OUT.PRINTLN (ss);}
Caused by:java.sql.sqlexception:ora-01795: The maximum number of expressions in the list is 1000 solution