title: Cannot add an ORDER BY command to a stored procedure
body: <p>I'm converting a stored procedure in some software I'm maintaining from SQL Server SQL to Informix SQL, and problems are abundant.</p>
  
  <p>Basically I'm converting each section line-by-line until I have the whole thing converted.</p>
  
  <p>I have the following <code>CREATE PROCEDURE</code>:</p>
  
  <pre><code>CREATE PROCEDURE ifxdbase:dc_buildSP (WorkID INT, CompNo smallint)
  CREATE TEMP TABLE Items
  (
     Code smallint,
     Qty int,
     Total int
  );
  
  INSERT INTO Items
  SELECT 
     tblDetails.code, 
     tblDetails.quantity,
     tblHead.quantity
  FROM
     tblHead
  INNER JOIN tblDetails ON (tblDetails.compno = tblDetails.compno AND tblDetails.id_num = tblHead.id_num)
  WHERE tblHead.compno = CompNo AND tblHead.id_num = WorkID;
  --ORDER BY tblDetails.code;
  
  DROP TABLE Items;
  END PROCEDURE
  </code></pre>
  
  <p>As it stands, this works fine, but when I uncomment the line <code>--ORDER BY tblDetails.seqno;</code> (and remove the semicolon from the previous line) I get a "-201 A syntax error has occurred" error.</p>
  
  <p>Basically <code>tblHead</code> is a series of order headers and <code>tblDetails</code> is a table of the details of each of those orders. Selecting and joining the data works fine, trying to order it fails.</p>
  
  <p>Ordering should work with anything from the original SELECT, IIRC, so I can't see what could be going wrong, here...</p>