title: How to force table select to go over blocks
body: <p>How can I make Sybase's database engine return an unsorted list of records in non-numeric order?</p>
  
  <p>~~~</p>
  
  <p>I have an issue where I need to reproduce an error in the application where I select from a table where the ID is generated in sequence, but the ID is not the last one in the selection.</p>
  
  <p>Let me explain.</p>
  
  <pre><code>ID    STATUS
  _____________
  1234   C
  1235   C
  1236   O
  </code></pre>
  
  <p>Above is 3 IDs. I had code where these would be the results of a </p>
  
  <pre><code>select @p_id = ID from table where (conditions).
  </code></pre>
  
  <p>However, there wasn't a clause to check for status = 'O' (open). Remember Sybase saves the last returned record into a variable.</p>
  
  <p>~~~~~</p>
  
  <p>I'm being asked to give the testing team something that will make the results not work. If Sybase selects the above in an unordered list, it could appear in ascending order, or, if the database engine needs to change blocks of stored data or something technical magic stuff, the order could be messed up. The original error was when the procedure would return say 1234 instead of 1236.</p>
  
  <p>Is there a way that I can have a <strong>100% guarantee</strong> that Sybase will search over a block of data and have to double back, effectively 'breaking' the ascending search, and returning not the last record, but any other one? (all records except the maximum will end up erroring, because they are all 'Closed')</p>
  
  <p>I want some sort of magical SQL code that will make sure things don't search the table in exactly numeric order. Ideally I'd like to not have to change the procedure, as the test team want to see the exact same procedure breaking (as easy as plonking a <code>order by id desc</code> would fudge the results).</p>