Is there a workaround for ORA-01795: maximum number of expressions in a list is 1000 error?

前端 未结 11 889
忘掉有多难
忘掉有多难 2020-11-27 16:14

Is there a workaround for

\'ORA-01795: maximum number of expressions in a list is 1000 error\'

I have a query and it is selecting fields based

11条回答
  •  一生所求
    2020-11-27 17:04

        **Divide a list to lists of n size**
    
        import java.util.AbstractList;
        import java.util.ArrayList;
        import java.util.List;
    
        public final class PartitionUtil extends AbstractList> {
    
            private final List list;
            private final int chunkSize;
    
            private PartitionUtil(List list, int chunkSize) {
                this.list = new ArrayList<>(list);
                this.chunkSize = chunkSize;
            }
    
            public static  PartitionUtil ofSize(List list, int chunkSize) {
                return new PartitionUtil<>(list, chunkSize);
            }
    
            @Override
            public List get(int index) {
                int start = index * chunkSize;
                int end = Math.min(start + chunkSize, list.size());
    
                if (start > end) {
                    throw new IndexOutOfBoundsException("Index " + index + " is out of the list range <0," + (size() - 1) + ">");
                }
    
                return new ArrayList<>(list.subList(start, end));
            }
    
            @Override
            public int size() {
                return (int) Math.ceil((double) list.size() / (double) chunkSize);
            }
        }
    
    
    
    
    
    Function call : 
                  List> containerNumChunks = PartitionUtil.ofSize(list, 999)
    

    more details: https://e.printstacktrace.blog/divide-a-list-to-lists-of-n-size-in-Java-8/

提交回复
热议问题