Oracle can’t handle more than 1000 expressions in a single in clause. (Really stupid restriction, I know and here’s the tip: you can do (, ,,,,,) or **abc** in (,,,,,,) ad infinitum).

When compilers software pipeline a loop, they calculate two things at first. The remainder and the dividend.

(This post got too keyword heavy. Matrix fans will curse me that its the other Oracle. That Oracle’s users will not find all ORA-xyz error descriptions here. Architects may not have any interest in writing computer code. Computer architects will not see any processors discussed. One post to rule them all. ]:) )

The problem at hand was hand generating a query with in clause in its where section. Number of expressions was unbounded. And the genius who came up with the loop did this:

for( int i = 0 , n = 0 ; i < count ; ++i )

{

n++;

if( n == 1000 )

{

quwry += " ) or in ( ";

n = 0;

}

query += list [ i ] + ‘,’;

}

query = query.Remove( query.Length – 1 , 1 );

Remember this is the work of someone who has never heard about software pipeline and may never know what gcc or cl are. Thinking one level above will help us arrive at the correct solution (notice, there is nothing wrong functionally with the above code either. It does what it says it does.):

int n = numbers.Count / stride , k = numbers.Count % stride;

StringBuilder builder = new StringBuilder( );

if( n > 0 )

{

builder.AppendFormat( "'{0}’" , numbers [ 0 ] );

for( int j = 1 ; j < stride ; j++ )

builder.AppendFormat( " , ‘{0}’ " , numbers [ j ] );

for( int i = 1 ; i < n ; ++i )

{

builder.Append( separator );

builder.AppendFormat( "'{0}’" , numbers [ i * stride ] );

for( int j = i * stride + 1 ; j < ( i + 1 ) * stride ; j++ )

builder.AppendFormat( " , ‘{0}’ " , numbers [ j ] );

}

}

if( k > 0 )

{

if( n > 0 )

builder.Append( separator );

builder.AppendFormat( "'{0}’" , numbers [ n * stride ] );

for( int j = n * stride + 1 ; j < numbers.Count ; ++j )

builder.AppendFormat( " , ‘{0}’ " , numbers [ j ] );

}

No repetitive checking of one variable which also displays off-by-1 error. And which is also mission the other correction in first line of this post in bold.